RamshaAnwar commited on
Commit
f06652d
·
1 Parent(s): c93af42

fix(hf): override gradio launch to run fastapi server

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- # Start the server manually so FastAPI routes work.
20
- if __name__ == "__main__":
21
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
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