Spaces:
Sleeping
Sleeping
Commit ·
7fb89ca
1
Parent(s): c61e92b
Gradio default /ui
Browse files
app.py
CHANGED
|
@@ -9,8 +9,8 @@ from threading import Lock
|
|
| 9 |
from typing import Any, Dict
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
-
from fastapi import FastAPI
|
| 13 |
-
from fastapi.responses import
|
| 14 |
|
| 15 |
import sys
|
| 16 |
|
|
@@ -27,36 +27,6 @@ _env = CodeReviewEnv()
|
|
| 27 |
_lock = Lock()
|
| 28 |
|
| 29 |
|
| 30 |
-
@app.get("/")
|
| 31 |
-
def root(request: Request):
|
| 32 |
-
accept = request.headers.get("accept", "")
|
| 33 |
-
# Humans opening the Space in a browser should land on Gradio UI directly.
|
| 34 |
-
if "text/html" in accept and "application/json" not in accept:
|
| 35 |
-
return HTMLResponse(
|
| 36 |
-
"""
|
| 37 |
-
<!doctype html>
|
| 38 |
-
<html>
|
| 39 |
-
<head>
|
| 40 |
-
<meta charset=\"utf-8\" />
|
| 41 |
-
<meta http-equiv=\"refresh\" content=\"0; url=/ui\" />
|
| 42 |
-
<script>window.location.replace('/ui');</script>
|
| 43 |
-
<title>Loading UI...</title>
|
| 44 |
-
</head>
|
| 45 |
-
<body style=\"font-family: sans-serif; padding: 24px;\">
|
| 46 |
-
Redirecting to <a href=\"/ui\">/ui</a>...
|
| 47 |
-
</body>
|
| 48 |
-
</html>
|
| 49 |
-
"""
|
| 50 |
-
)
|
| 51 |
-
|
| 52 |
-
return {
|
| 53 |
-
"status": "ok",
|
| 54 |
-
"service": "code-review-agent-env",
|
| 55 |
-
"ui": "/ui",
|
| 56 |
-
"endpoints": ["/health", "/tasks", "/reset", "/step", "/state", "/score", "/ui"],
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
|
| 60 |
@app.get("/health")
|
| 61 |
def health() -> Dict[str, str]:
|
| 62 |
return {"status": "healthy"}
|
|
@@ -340,4 +310,9 @@ with gr.Blocks(title="Code Review Agent Environment") as demo:
|
|
| 340 |
refresh_tasks_btn.click(fn=_task_table, inputs=None, outputs=[task_grid])
|
| 341 |
|
| 342 |
|
| 343 |
-
app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from typing import Any, Dict
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
+
from fastapi import FastAPI
|
| 13 |
+
from fastapi.responses import RedirectResponse
|
| 14 |
|
| 15 |
import sys
|
| 16 |
|
|
|
|
| 27 |
_lock = Lock()
|
| 28 |
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
@app.get("/health")
|
| 31 |
def health() -> Dict[str, str]:
|
| 32 |
return {"status": "healthy"}
|
|
|
|
| 310 |
refresh_tasks_btn.click(fn=_task_table, inputs=None, outputs=[task_grid])
|
| 311 |
|
| 312 |
|
| 313 |
+
@app.get("/ui")
|
| 314 |
+
def ui_alias() -> Any:
|
| 315 |
+
return RedirectResponse(url="/", status_code=307)
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|