19 行
558 B
Python
19 行
558 B
Python
"""LaTeX 速查表 API:AP 数理化生四科常用 LaTeX(数据在 data/latex_sheet.json)。"""
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
from pathlib import Path
|
||
|
||
from fastapi import APIRouter, HTTPException
|
||
|
||
router = APIRouter(prefix="/latex", tags=["latex"])
|
||
|
||
_SHEET_PATH = Path(__file__).resolve().parents[3] / "data" / "latex_sheet.json"
|
||
|
||
|
||
@router.get("/sheet")
|
||
async def latex_sheet():
|
||
if not _SHEET_PATH.exists():
|
||
raise HTTPException(404, "速查表数据缺失")
|
||
return json.loads(_SHEET_PATH.read_text(encoding="utf-8"))
|