Spaces:
Sleeping
Sleeping
Commit ·
8b9bfa4
1
Parent(s): b435d15
Modified launching
Browse files- app.py +13 -6
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -252,6 +252,8 @@ APP_CSS = """
|
|
| 252 |
# Build immersive chat interface with overlay
|
| 253 |
with gr.Blocks(
|
| 254 |
title="GCP - Game Context Protocol",
|
|
|
|
|
|
|
| 255 |
) as demo:
|
| 256 |
# Initialize JavaScript functionality (minimal essentials only)
|
| 257 |
gr.HTML("""
|
|
@@ -511,11 +513,16 @@ if __name__ == "__main__":
|
|
| 511 |
demo.queue()
|
| 512 |
|
| 513 |
if IS_HF_SPACES:
|
| 514 |
-
# On HF Spaces:
|
| 515 |
-
#
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
else:
|
| 520 |
-
# Local dev: FastAPI already running on 8000, just launch Gradio on 7860
|
| 521 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 252 |
# Build immersive chat interface with overlay
|
| 253 |
with gr.Blocks(
|
| 254 |
title="GCP - Game Context Protocol",
|
| 255 |
+
theme=gr.themes.Soft(),
|
| 256 |
+
css=APP_CSS,
|
| 257 |
) as demo:
|
| 258 |
# Initialize JavaScript functionality (minimal essentials only)
|
| 259 |
gr.HTML("""
|
|
|
|
| 513 |
demo.queue()
|
| 514 |
|
| 515 |
if IS_HF_SPACES:
|
| 516 |
+
# On HF Spaces: Both FastAPI and Gradio must share port 7860
|
| 517 |
+
# Mount Gradio at root, FastAPI routes are already on fastapi_app
|
| 518 |
+
print("🚀 Starting on HF Spaces - mounting Gradio on FastAPI")
|
| 519 |
+
|
| 520 |
+
# Mount Gradio onto FastAPI at root path
|
| 521 |
+
# Note: Gradio will handle "/" and its own routes, FastAPI handles /view/*, /api/*, /health
|
| 522 |
+
combined_app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 523 |
+
|
| 524 |
+
# Run combined app
|
| 525 |
+
uvicorn.run(combined_app, host="0.0.0.0", port=7860, log_level="info")
|
| 526 |
else:
|
| 527 |
+
# Local dev: FastAPI already running on 8000 (started above), just launch Gradio on 7860
|
| 528 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
CHANGED
|
@@ -7,7 +7,7 @@ requests
|
|
| 7 |
mcp>=1.0.0
|
| 8 |
|
| 9 |
# Chat Interface
|
| 10 |
-
gradio
|
| 11 |
|
| 12 |
# LLM
|
| 13 |
openai
|
|
|
|
| 7 |
mcp>=1.0.0
|
| 8 |
|
| 9 |
# Chat Interface
|
| 10 |
+
gradio
|
| 11 |
|
| 12 |
# LLM
|
| 13 |
openai
|