Spaces:
Running
Running
Update project/unified_server.py
Browse files
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 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 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
|
| 88 |
-
app = gr.mount_gradio_app(app, test_demo, path="/gradio-test"
|
| 89 |
-
app = gr.mount_gradio_app(app, chat_demo, path="/gradio-chat"
|
| 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")
|