owenkaplinsky commited on
Commit
27854a8
·
verified ·
1 Parent(s): 46d597d

Update project/unified_server.py

Browse files
Files changed (1) hide show
  1. project/unified_server.py +7 -9
project/unified_server.py CHANGED
@@ -12,12 +12,10 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
12
  import test
13
  import chat
14
 
15
- # Respect Hugging Face Spaces reverse proxy path/prefix when present
16
- root_path = os.environ.get("SPACE_ROOT_PATH", "")
17
- # Ensure Gradio emits proxied asset URLs (avoid 0.0.0.0/http)
18
- os.environ["GRADIO_ROOT_PATH"] = root_path
19
-
20
- app = FastAPI(root_path=root_path)
21
 
22
  app.add_middleware(
23
  CORSMiddleware,
@@ -84,9 +82,9 @@ app.mount("/assets", StaticFiles(directory=frontend_dir), name="assets")
84
  test_demo = test.get_gradio_interface()
85
  chat_demo = chat.get_chat_gradio_interface()
86
 
87
- # Mount the Gradio apps directly (propagate root_path so assets & SSE routes are correct)
88
- app = gr.mount_gradio_app(app, test_demo, path="/gradio-test", root_path=root_path)
89
- app = gr.mount_gradio_app(app, chat_demo, path="/gradio-chat", root_path=root_path)
90
 
91
  print("new /gradio-test")
92
  print("new /gradio-chat")
 
12
  import test
13
  import chat
14
 
15
+ app = FastAPI(
16
+ # Respect Hugging Face Spaces reverse proxy path/prefix when present
17
+ root_path=os.environ.get("SPACE_ROOT_PATH", "")
18
+ )
 
 
19
 
20
  app.add_middleware(
21
  CORSMiddleware,
 
82
  test_demo = test.get_gradio_interface()
83
  chat_demo = chat.get_chat_gradio_interface()
84
 
85
+ # Mount the Gradio apps directly
86
+ app = gr.mount_gradio_app(app, test_demo, path="/gradio-test")
87
+ app = gr.mount_gradio_app(app, chat_demo, path="/gradio-chat")
88
 
89
  print("new /gradio-test")
90
  print("new /gradio-chat")