Python 后端提交
Python 后端(FastAPI + FastMCP + ...)的初始版本号设定为 0.1.0,这是 uv 在 pypriject.toml 里给我自动设置的,我觉得有道理。
This commit is contained in:
22
router/webui_router.py
Normal file
22
router/webui_router.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user