You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
669 B
25 lines
669 B
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi import HTTPException
|
|
from fastapi.responses import FileResponse
|
|
|
|
|
|
router = APIRouter()
|
|
WEB_DIR = Path(__file__).resolve().parent
|
|
DIST_DIR = WEB_DIR / "dist"
|
|
INDEX_FILE = DIST_DIR / "index.html"
|
|
|
|
|
|
def _get_index_file() -> Path:
|
|
if not INDEX_FILE.exists():
|
|
raise HTTPException(status_code=503, detail="Web UI assets are not built.")
|
|
return INDEX_FILE
|
|
|
|
|
|
@router.get("/app", include_in_schema=False)
|
|
@router.get("/app/{path:path}", include_in_schema=False)
|
|
async def web_app(_path: str = "") -> FileResponse:
|
|
return FileResponse(_get_index_file())
|
|
|