File size: 519 Bytes
d3a7520 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """简单的模板与静态资源加载工具。"""
from __future__ import annotations
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent
TEMPLATE_DIR = BASE_DIR / "templates"
STATIC_DIR = BASE_DIR / "static"
def load_template(name: str) -> str:
"""读取模板文件内容。"""
path = TEMPLATE_DIR / name
return path.read_text(encoding="utf-8")
def get_static_path(name: str) -> Path:
"""返回静态资源的绝对路径路径。"""
return (STATIC_DIR / name).resolve()
|