更新
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""帮助中心静态页面。"""
|
||||
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",
|
||||
)
|
||||
Reference in New Issue
Block a user