|
import gradio as gr |
|
import uvicorn |
|
|
|
import requests |
|
|
|
import json |
|
|
|
|
|
|
|
def check_progress(): |
|
resp = requests.get("http://3.88.103.173/finetuning/progress/1679038378_70") |
|
print(resp.text) |
|
return json.loads(resp.text) |
|
|
|
def reverse(text): |
|
return text[::-1] |
|
|
|
with gr.Blocks() as demo: |
|
button = gr.Button(value="Reverse") |
|
button.click(reverse, gr.Textbox(), gr.Textbox()) |
|
|
|
|
|
|
|
app, local_url, share_url = demo.launch(prevent_thread_lock=True) |
|
print(app) |
|
print(local_url) |
|
print(share_url) |
|
ret = app.add_api_route("/progress", check_progress, methods=["GET"]) |
|
print(ret) |
|
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=7861) |