iamudit02 commited on
Commit
fa354cc
·
1 Parent(s): 314ea3e

fix: include fastapi_app.router on demo.app so /api routes take priority

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -44,12 +44,19 @@ demo.app.add_middleware(
44
  allow_headers=["*"],
45
  )
46
 
47
- # Mount FastAPI app as root fallback so /api/*, /docs, /openapi.json, and /storage/* work seamlessly
48
- demo.app.mount("", fastapi_app)
49
 
50
- # Expose app for ASGI servers (Gunicorn/Uvicorn)
 
 
 
 
 
 
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
+