Spaces:
Runtime error
Runtime error
| from pathlib import Path | |
| from fastapi import APIRouter, HTTPException | |
| from fastapi.responses import FileResponse, RedirectResponse | |
| router = APIRouter() | |
| STATIC_DIR = Path(__file__).resolve().parents[3] / "_public" / "static" | |
| def _admin_page_response(relative_path: str) -> FileResponse: | |
| file_path = STATIC_DIR / relative_path | |
| if not file_path.exists(): | |
| raise HTTPException(status_code=404, detail="Page not found") | |
| return FileResponse(file_path) | |
| async def admin_root(): | |
| return RedirectResponse(url="/admin/login") | |
| async def admin_login(): | |
| return _admin_page_response("admin/pages/login.html") | |
| async def admin_config(): | |
| return _admin_page_response("admin/pages/config.html") | |
| async def admin_cache(): | |
| return _admin_page_response("admin/pages/cache.html") | |
| async def admin_token(): | |
| return _admin_page_response("admin/pages/token.html") | |