Spaces:
Runtime error
Runtime error
Commit ·
f06652d
1
Parent(s): c93af42
fix(hf): override gradio launch to run fastapi server
Browse files
app.py
CHANGED
|
@@ -13,9 +13,13 @@ demo = gr.Interface(
|
|
| 13 |
description="This is the backend API for ContextQuery AI."
|
| 14 |
)
|
| 15 |
|
| 16 |
-
# Mount FastAPI
|
| 17 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
description="This is the backend API for ContextQuery AI."
|
| 14 |
)
|
| 15 |
|
| 16 |
+
# Mount Gradio into FastAPI
|
| 17 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 18 |
|
| 19 |
+
# Override the launch method.
|
| 20 |
+
# Hugging Face's runner automatically calls demo.launch().
|
| 21 |
+
# We replace it with our own function that starts the FastAPI server instead.
|
| 22 |
+
def custom_launch(*args, **kwargs):
|
| 23 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 24 |
+
|
| 25 |
+
demo.launch = custom_launch
|