Files
NJUPT-Suan-API/router/webui_router.py
MangoFanFanw b284c3c260 Python 后端提交
Python 后端(FastAPI + FastMCP + ...)的初始版本号设定为 0.1.0,这是 uv 在 pypriject.toml
里给我自动设置的,我觉得有道理。
2026-04-21 13:38:46 +08:00

23 lines
795 B
Python

from pathlib import Path
import aiofiles
from fastapi import APIRouter
from fastapi.responses import HTMLResponse
WEBUI_INDEX = Path.cwd() / "webui" / "dist" / "index.html"
SCHEDULE_INDEX = Path.cwd() / "webui" / "dist" / "index-schedule.html"
webui_router = APIRouter(prefix="/webui")
@webui_router.get("/", response_class=HTMLResponse)
async def get_webui() -> HTMLResponse:
async with aiofiles.open(file=WEBUI_INDEX, mode="r", encoding="utf-8") as f:
return HTMLResponse(content=await f.read(), status_code=200)
@webui_router.get("/schedule", response_class=HTMLResponse)
async def get_webui_schedule() -> HTMLResponse:
async with aiofiles.open(file=SCHEDULE_INDEX, mode="r", encoding="utf-8") as f:
return HTMLResponse(content=await f.read(), status_code=200)