yukee1992 commited on
Commit
0fefc87
·
verified ·
1 Parent(s): d109575

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -811,9 +811,8 @@ def create_gradio_interface():
811
  # Create Gradio app
812
  gradio_app = create_gradio_interface()
813
 
814
- # Mount Gradio under a specific path to avoid conflicts
815
- from fastapi.middleware.wsgi import WSGIMiddleware
816
- app.mount("/ui", WSGIMiddleware(gradio_app.server))
817
 
818
  # Enhanced root endpoint that explains the API structure
819
  @app.get("/")
@@ -858,12 +857,11 @@ if __name__ == "__main__":
858
 
859
  # On Hugging Face, we need to run only one server
860
  # Gradio will be mounted at /ui, FastAPI at root
861
- gradio_app.launch(
862
- server_name="0.0.0.0",
863
- server_port=7860,
864
- share=False,
865
- show_error=True,
866
- quiet=False
867
  )
868
  else:
869
  # Local development - run separate servers
 
811
  # Create Gradio app
812
  gradio_app = create_gradio_interface()
813
 
814
+ # FIXED: Mount Gradio correctly - Create a separate FastAPI app for Gradio
815
+ gradio_fastapi_app = gr.mount_gradio_app(app, gradio_app, path="/ui")
 
816
 
817
  # Enhanced root endpoint that explains the API structure
818
  @app.get("/")
 
857
 
858
  # On Hugging Face, we need to run only one server
859
  # Gradio will be mounted at /ui, FastAPI at root
860
+ uvicorn.run(
861
+ app,
862
+ host="0.0.0.0",
863
+ port=7860,
864
+ log_level="info"
 
865
  )
866
  else:
867
  # Local development - run separate servers