Files
dy/backend/help_pages.py
2026-07-23 17:56:25 +08:00

30 lines
823 B
Python

"""帮助中心静态页面。"""
from pathlib import Path
from fastapi import HTTPException
from fastapi.responses import FileResponse
from settings import BACKEND_DIR, PROJECT_ROOT
HELP_STATIC_DIR = BACKEND_DIR / "static" / "help"
CREDENTIAL_TOOL_CANDIDATES = (
PROJECT_ROOT / "凭证采集工具.html",
HELP_STATIC_DIR / "credential-tool.html",
)
def _resolve_credential_tool_html() -> Path:
for path in CREDENTIAL_TOOL_CANDIDATES:
if path.is_file():
return path
raise HTTPException(status_code=404, detail="凭证采集工具页面不存在")
def serve_credential_tool() -> FileResponse:
html_path = _resolve_credential_tool_html()
return FileResponse(
html_path,
media_type="text/html; charset=utf-8",
content_disposition_type="inline",
)