yukee1992 commited on
Commit
5eee929
ยท
verified ยท
1 Parent(s): 0fefc87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -811,9 +811,6 @@ def create_gradio_interface():
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("/")
819
  async def root():
@@ -838,7 +835,7 @@ async def test_endpoint():
838
  "timestamp": datetime.now().isoformat()
839
  }
840
 
841
- # For Hugging Face Spaces deployment
842
  def get_app():
843
  return app
844
 
@@ -855,8 +852,11 @@ if __name__ == "__main__":
855
  print("๐ŸŽจ Web interface available at: /ui")
856
  print("๐Ÿ”Œ Both API and UI running on same port")
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",
@@ -904,4 +904,5 @@ if __name__ == "__main__":
904
  while True:
905
  time.sleep(1)
906
  except KeyboardInterrupt:
907
- print("๐Ÿ›‘ Shutting down servers...")
 
 
811
  # Create Gradio app
812
  gradio_app = create_gradio_interface()
813
 
 
 
 
814
  # Enhanced root endpoint that explains the API structure
815
  @app.get("/")
816
  async def root():
 
835
  "timestamp": datetime.now().isoformat()
836
  }
837
 
838
+ # For Hugging Face Spaces deployment - SIMPLIFIED APPROACH
839
  def get_app():
840
  return app
841
 
 
852
  print("๐ŸŽจ Web interface available at: /ui")
853
  print("๐Ÿ”Œ Both API and UI running on same port")
854
 
855
+ # On Hugging Face Spaces, we need to properly integrate both
856
+ # Mount Gradio app to FastAPI
857
+ app = gr.mount_gradio_app(app, gradio_app, path="/ui")
858
+
859
+ # Run the combined app
860
  uvicorn.run(
861
  app,
862
  host="0.0.0.0",
 
904
  while True:
905
  time.sleep(1)
906
  except KeyboardInterrupt:
907
+ print("๐Ÿ›‘ Shutting down servers...")
908
+