Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,26 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
import gradio as gr
|
| 3 |
-
|
| 4 |
-
app = FastAPI()
|
| 5 |
|
| 6 |
def echo(message):
|
| 7 |
return message
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
)
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
app =
|
| 18 |
|
| 19 |
@app.get("/hello")
|
| 20 |
-
def
|
| 21 |
-
return
|
| 22 |
|
| 23 |
-
|
| 24 |
-
def hello_world():
|
| 25 |
-
return {"message": "Hello, World!"}
|
| 26 |
|
| 27 |
-
|
| 28 |
-
import uvicorn
|
| 29 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastapi import FastAPI
|
|
|
|
| 3 |
|
| 4 |
def echo(message):
|
| 5 |
return message
|
| 6 |
|
| 7 |
+
def hello_world():
|
| 8 |
+
return {"message": "Hello, World!"}
|
| 9 |
+
|
| 10 |
+
with gr.Blocks() as demo:
|
| 11 |
+
gr.Markdown("# Echo App")
|
| 12 |
+
with gr.Row():
|
| 13 |
+
input_text = gr.Textbox(label="Input")
|
| 14 |
+
output_text = gr.Textbox(label="Output")
|
| 15 |
+
button = gr.Button("Echo")
|
| 16 |
+
button.click(fn=echo, inputs=input_text, outputs=output_text)
|
| 17 |
|
| 18 |
+
app = FastAPI()
|
| 19 |
|
| 20 |
@app.get("/hello")
|
| 21 |
+
async def hello():
|
| 22 |
+
return hello_world()
|
| 23 |
|
| 24 |
+
gr.mount_gradio_app(app, demo, path="/")
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
# Hugging Face Spaces will automatically use this app
|
|
|
|
|
|