Download src/web/template_loader.py from ServiceX/PDF: direct link, hf CLI and curl.
- Browser
- Download file 519 Bytes
-
https://huggingface.co/spaces/ServiceX/PDF/resolve/main/src/web/template_loader.py
- Command line
-
hf download hf://spaces/ServiceX/PDF/src/web/template_loader.py
-
curl -L -o template_loader.py https://huggingface.co/spaces/ServiceX/PDF/resolve/main/src/web/template_loader.py
519 Bytes
| """简单的模板与静态资源加载工具。""" | |
| 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() | |