Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Créer FastAPI
|
| 5 |
+
api = FastAPI()
|
| 6 |
+
|
| 7 |
+
@api.get("/ping")
|
| 8 |
+
def ping():
|
| 9 |
+
return {"status": "ok"}
|
| 10 |
+
|
| 11 |
+
# Créer Gradio
|
| 12 |
+
def echo(name):
|
| 13 |
+
return f"Hello {name}"
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(fn=echo, inputs="text", outputs="text")
|
| 16 |
+
|
| 17 |
+
# Monter Gradio dans FastAPI
|
| 18 |
+
app = gr.mount_gradio_app(api, demo, path="/gradio")
|