Spaces:
Sleeping
Sleeping
Deploy build-b99d714
Browse files- backend/main.py +8 -1
backend/main.py
CHANGED
|
@@ -787,14 +787,21 @@ try:
|
|
| 787 |
import gradio as gr
|
| 788 |
from frontend.app import demo as gradio_demo # the gr.Blocks() object
|
| 789 |
|
| 790 |
-
# Mount Gradio at
|
| 791 |
# registered first via @app.get / @app.post decorators.
|
| 792 |
app = gr.mount_gradio_app(app, gradio_demo, path="/ui")
|
| 793 |
logger.info("Gradio UI mounted at /ui — full app on single port.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 794 |
except Exception as _e:
|
| 795 |
logger.warning(f"Gradio mount skipped ({_e}). API-only mode active.")
|
| 796 |
|
| 797 |
|
|
|
|
| 798 |
if __name__ == "__main__":
|
| 799 |
import uvicorn
|
| 800 |
port = int(os.getenv("PORT", "7860"))
|
|
|
|
| 787 |
import gradio as gr
|
| 788 |
from frontend.app import demo as gradio_demo # the gr.Blocks() object
|
| 789 |
|
| 790 |
+
# Mount Gradio at /ui; FastAPI routes take priority because they're
|
| 791 |
# registered first via @app.get / @app.post decorators.
|
| 792 |
app = gr.mount_gradio_app(app, gradio_demo, path="/ui")
|
| 793 |
logger.info("Gradio UI mounted at /ui — full app on single port.")
|
| 794 |
+
|
| 795 |
+
from fastapi.responses import RedirectResponse
|
| 796 |
+
@app.get("/")
|
| 797 |
+
def redirect_to_ui():
|
| 798 |
+
return RedirectResponse(url="/ui")
|
| 799 |
+
|
| 800 |
except Exception as _e:
|
| 801 |
logger.warning(f"Gradio mount skipped ({_e}). API-only mode active.")
|
| 802 |
|
| 803 |
|
| 804 |
+
|
| 805 |
if __name__ == "__main__":
|
| 806 |
import uvicorn
|
| 807 |
port = int(os.getenv("PORT", "7860"))
|