fixed cache

This commit is contained in:
2026-04-02 14:50:07 -05:00
parent 9f179295d8
commit a7d3af4ddd
2 changed files with 23 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
import asyncio
import hashlib
import json
import os
import re
@@ -71,6 +72,20 @@ if os.path.isdir(_ICONS_DIR):
templates = Jinja2Templates(directory=os.path.join(_BASE_DIR, "templates"))
# ── Static asset cache-busting ────────────────────────────────────
def _file_hash(filename: str) -> str:
"""Return first 8 chars of the MD5 hex digest for a static file."""
path = os.path.join(_BASE_DIR, "static", filename)
try:
with open(path, "rb") as f:
return hashlib.md5(f.read()).hexdigest()[:8]
except FileNotFoundError:
return "0"
_APP_JS_HASH = _file_hash("app.js")
_STYLE_CSS_HASH = _file_hash("style.css")
# ── Update check helpers ─────────────────────────────────────────
def _get_locked_info():
@@ -230,11 +245,15 @@ def _resolve_credential(cred: dict) -> dict | None:
return {"label": label, "value": value, "multiline": multiline}
# ── Routes ──────────────────────────────────────────────────────
# ── Routes ───────────<EFBFBD><EFBFBD>───────────────────────────────────────────
@app.get("/", response_class=HTMLResponse)
async def index(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
return templates.TemplateResponse("index.html", {
"request": request,
"app_js_hash": _APP_JS_HASH,
"style_css_hash": _STYLE_CSS_HASH,
})
@app.get("/api/config")