Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,29 @@
|
|
| 1 |
import os
|
| 2 |
import uvicorn
|
| 3 |
from fastapi import FastAPI
|
| 4 |
-
from fastapi.middleware.wsgi import WSGIMiddleware
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
from api import api_app
|
| 8 |
from main import build_ui
|
| 9 |
|
| 10 |
-
# Create
|
| 11 |
app = FastAPI()
|
| 12 |
|
| 13 |
# Mount API under /api
|
| 14 |
app.mount("/api", api_app)
|
| 15 |
|
| 16 |
-
# Build
|
| 17 |
demo = build_ui()
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
| 23 |
-
port = int(os.environ.get("PORT", 7860))
|
| 24 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import uvicorn
|
| 3 |
from fastapi import FastAPI
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
from api import api_app
|
| 7 |
from main import build_ui
|
| 8 |
|
| 9 |
+
# Create FastAPI app
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
# Mount API under /api
|
| 13 |
app.mount("/api", api_app)
|
| 14 |
|
| 15 |
+
# Build Gradio demo
|
| 16 |
demo = build_ui()
|
| 17 |
|
| 18 |
+
# ✅ Correct: mount Gradio inside FastAPI (does not spawn its own server)
|
| 19 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
| 22 |
+
port = int(os.environ.get("PORT", 7860)) # Hugging Face uses $PORT
|
| 23 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
+
|