refac: modularize apis VII

This commit is contained in:
Alpha Nerd 2026-05-19 14:57:39 +02:00
parent e74f5d1ba6
commit 4b5a70e787
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M
7 changed files with 2244 additions and 2108 deletions

30
api/static.py Normal file
View file

@ -0,0 +1,30 @@
"""Static-asset and dashboard routes."""
from pathlib import Path
from fastapi import APIRouter, HTTPException, Request
from starlette.responses import HTMLResponse, RedirectResponse
# Directory containing static files (resolved relative to project root).
STATIC_DIR = Path(__file__).resolve().parent.parent / "static"
router = APIRouter()
@router.get("/favicon.ico")
async def redirect_favicon():
return RedirectResponse(url="/static/favicon.ico")
@router.get("/", response_class=HTMLResponse)
async def index(request: Request):
"""
Render the dynamic NOMYO Router dashboard listing the configured endpoints
and the models details, availability & task status.
"""
index_path = STATIC_DIR / "index.html"
try:
return HTMLResponse(content=index_path.read_text(encoding="utf-8"), status_code=200)
except FileNotFoundError:
raise HTTPException(status_code=404, detail="Page not found")
except Exception:
raise HTTPException(status_code=500, detail="Internal server error")