demo-service: fix .draft/.bak HTML files downloaded instead of rendered

The site_content endpoint only checked for .html suffix to render
inline. Hidden HTML fallbacks (.index.html.draft, .index.html.bak)
have .draft or .bak suffixes, so they fell through to FileResponse
which triggered browser download instead of rendering.

Fix: also check for .draft and .bak suffixes.
This commit is contained in:
Junv (via Hermes)
2026-07-13 10:10:57 +10:00
parent 76f9e33a4c
commit c069b1f5ff
+2 -1
View File
@@ -175,7 +175,8 @@ async def site_content(path: str = "", request: Request = None):
resp.headers["Cache-Control"] = "no-store"
return resp
# HTML files render inline; others (CSS, JS, images) are served as files
if target.suffix == ".html":
# .draft and .bak are hidden HTML fallbacks (e.g. .index.html.draft)
if target.suffix == ".html" or target.suffix in (".draft", ".bak"):
return HTMLResponse(target.read_text())
resp = FileResponse(target)
resp.headers["Content-Disposition"] = "inline"