Spaces:
Runtime error
Runtime error
fix: include fastapi_app.router on demo.app so /api routes take priority
Browse files
app.py
CHANGED
|
@@ -44,12 +44,19 @@ demo.app.add_middleware(
|
|
| 44 |
allow_headers=["*"],
|
| 45 |
)
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
demo.app.
|
| 49 |
|
| 50 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
app = demo.app
|
| 52 |
|
| 53 |
if __name__ == "__main__":
|
| 54 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 55 |
|
|
|
|
|
|
| 44 |
allow_headers=["*"],
|
| 45 |
)
|
| 46 |
|
| 47 |
+
# Register all FastAPI routes directly onto Gradio's FastAPI application so /api/*, /docs, /openapi.json take priority over Gradio's catch-all
|
| 48 |
+
demo.app.include_router(fastapi_app.router)
|
| 49 |
|
| 50 |
+
# Mount static file directory for student photos and exports
|
| 51 |
+
import os
|
| 52 |
+
from fastapi.staticfiles import StaticFiles
|
| 53 |
+
os.makedirs(settings.STORAGE_DIR, exist_ok=True)
|
| 54 |
+
demo.app.mount("/storage", StaticFiles(directory=settings.STORAGE_DIR), name="storage")
|
| 55 |
+
|
| 56 |
+
# Expose app for ASGI servers
|
| 57 |
app = demo.app
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 61 |
|
| 62 |
+
|