mirror of
https://github.com/wahyd4/home-docker.git
synced 2026-08-08 20:15:03 +10:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user