Files
banban/talkingq-url/api/wechat_verify.py
2026-07-07 16:58:05 +08:00

19 lines
648 B
Python

from pathlib import Path
from fastapi import APIRouter, HTTPException
from fastapi.responses import PlainTextResponse
router = APIRouter()
_VERIFY_FILES = {
"HXNd3XMbPq.txt": Path(__file__).resolve().parent.parent / "docs" / "HXNd3XMbPq.txt",
}
@router.get("/{filename}", response_class=PlainTextResponse, include_in_schema=False)
async def get_wechat_verify_file(filename: str) -> PlainTextResponse:
file_path = _VERIFY_FILES.get(filename)
if file_path is None or not file_path.is_file():
raise HTTPException(status_code=404, detail="Not Found")
return PlainTextResponse(file_path.read_text(encoding="utf-8").strip())