Download app/products/web/static_html.py from LifeVta/Grok3API: direct link, hf CLI and curl.
- Browser
- Download file 732 Bytes
-
https://huggingface.co/spaces/LifeVta/Grok3API/resolve/main/app/products/web/static_html.py
- Command line
-
hf download hf://spaces/LifeVta/Grok3API/app/products/web/static_html.py
-
curl -L -o static_html.py https://huggingface.co/spaces/LifeVta/Grok3API/resolve/main/app/products/web/static_html.py
732 Bytes
| """Helpers for serving static HTML with lightweight version injection.""" | |
| from pathlib import Path | |
| from fastapi import HTTPException | |
| from fastapi.responses import HTMLResponse | |
| from app.platform.meta import get_project_version | |
| _VERSION_TOKEN = "{{APP_VERSION}}" | |
| def serve_static_html(path: Path) -> HTMLResponse: | |
| """Serve an HTML file, replacing the version token if present.""" | |
| if not path.exists(): | |
| raise HTTPException(status_code=404, detail="Page not found") | |
| body = path.read_text(encoding="utf-8") | |
| if _VERSION_TOKEN in body: | |
| body = body.replace(_VERSION_TOKEN, get_project_version()) | |
| return HTMLResponse(body, headers={"Cache-Control": "no-store"}) | |
| __all__ = ["serve_static_html"] | |