Spaces:
Running on Zero
Running on Zero
| """Gradio Server routes and static frontend.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| from fastapi.responses import FileResponse | |
| from fastapi.staticfiles import StaticFiles | |
| from gradio import Server | |
| from app.config import STATIC_DIR | |
| from app.model_endpoint import model_status | |
| from app.service import analyze_notice | |
| from app.trace import trace_status | |
| app = Server() | |
| app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static") | |
| def analyze_api( | |
| text: str = "", | |
| image_data_url: str = "", | |
| example_id: str = "", | |
| save_trace: bool = True, | |
| output_language: str = "en", | |
| ) -> dict[str, Any]: | |
| return analyze_notice( | |
| text, | |
| image_data_url, | |
| example_id, | |
| save_trace, | |
| output_language, | |
| ) | |
| def status_api() -> dict[str, Any]: | |
| return model_status() | |
| def trace_status_api() -> dict[str, Any]: | |
| return trace_status() | |
| async def index() -> FileResponse: | |
| return FileResponse(STATIC_DIR / "index.html") | |
| async def health() -> dict[str, str]: | |
| return {"status": "ok"} | |