Stream dashboard index.html via FileResponse
This commit is contained in:
parent
29b3ccdbda
commit
291b565b4c
1 changed files with 5 additions and 6 deletions
|
|
@ -1,18 +1,17 @@
|
|||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
router = APIRouter(tags=["dashboard"])
|
||||
|
||||
_STATIC_DIR = Path(__file__).resolve().parent.parent / "static"
|
||||
_INDEX_HTML = (_STATIC_DIR / "index.html").read_text(encoding="utf-8")
|
||||
_INDEX_HTML_PATH = Path(__file__).resolve().parent.parent / "static" / "index.html"
|
||||
|
||||
|
||||
@router.get("/", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def dashboard() -> HTMLResponse:
|
||||
@router.get("/", include_in_schema=False)
|
||||
async def dashboard() -> FileResponse:
|
||||
"""Serve the operator dashboard. Static page that polls /health, /sources,
|
||||
/stats and /jobs from the browser. Auth happens via the bearer header the
|
||||
JS attaches to its fetches — the dashboard route itself is unauthenticated
|
||||
so an operator can open it in a browser and paste the token on demand."""
|
||||
return HTMLResponse(content=_INDEX_HTML)
|
||||
return FileResponse(_INDEX_HTML_PATH, media_type="text/html")
|
||||
|
|
|
|||
Loading…
Reference in a new issue