Upload folder using huggingface_hub
Browse files- server/app.py +7 -25
server/app.py
CHANGED
|
@@ -558,33 +558,15 @@ def create_gradio_app() -> gr.Blocks:
|
|
| 558 |
# ---------------------------------------------------------------------------
|
| 559 |
demo = create_gradio_app()
|
| 560 |
|
| 561 |
-
# Mount Gradio at
|
| 562 |
-
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 563 |
|
| 564 |
-
# Add
|
| 565 |
-
|
| 566 |
-
def reset_endpoint_final(req: ResetRequest = ResetRequest()):
|
| 567 |
-
"""OpenEnv-compliant reset endpoint."""
|
| 568 |
-
task_id = req.task_id if req else "easy"
|
| 569 |
-
temp_env = QuantumCircuitEnvironment(seed=42)
|
| 570 |
-
obs = temp_env.reset(config={"task_id": task_id})
|
| 571 |
-
return obs.dict() if hasattr(obs, "dict") else obs
|
| 572 |
-
|
| 573 |
-
@app.post("/step")
|
| 574 |
-
def step_endpoint_final(action: QuantumAction):
|
| 575 |
-
"""OpenEnv-compliant step endpoint."""
|
| 576 |
-
temp_env = QuantumCircuitEnvironment(seed=42)
|
| 577 |
-
temp_env.reset(config={"task_id": "easy"})
|
| 578 |
-
obs = temp_env.step(action)
|
| 579 |
-
return obs.dict() if hasattr(obs, "dict") else obs
|
| 580 |
|
| 581 |
-
@app.get("/
|
| 582 |
-
def
|
| 583 |
-
|
| 584 |
-
temp_env = QuantumCircuitEnvironment(seed=42)
|
| 585 |
-
temp_env.reset(config={"task_id": "easy"})
|
| 586 |
-
state = temp_env.state
|
| 587 |
-
return state.dict() if hasattr(state, "dict") else state
|
| 588 |
|
| 589 |
# ---------------------------------------------------------------------------
|
| 590 |
# Entry Point
|
|
|
|
| 558 |
# ---------------------------------------------------------------------------
|
| 559 |
demo = create_gradio_app()
|
| 560 |
|
| 561 |
+
# Mount Gradio at /ui instead of root to avoid route conflicts
|
| 562 |
+
app = gr.mount_gradio_app(fastapi_app, demo, path="/ui")
|
| 563 |
|
| 564 |
+
# Add root redirect to Gradio UI
|
| 565 |
+
from fastapi.responses import RedirectResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
|
| 567 |
+
@app.get("/")
|
| 568 |
+
async def root_redirect():
|
| 569 |
+
return RedirectResponse(url="/ui")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
|
| 571 |
# ---------------------------------------------------------------------------
|
| 572 |
# Entry Point
|