fix: robust HTML delivery for downloads section
CI / Test (Python 3.11) (push) Has been cancelled
CI / Test (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Type Check (push) Has been cancelled
CI / Summary (push) Has been cancelled

- Decoupled downloads container from main template to prevent static rendering errors
- Forced HTMX polling to use html=1 parameter
- Added server-side debug logging for request format detection
- Fixed Jinja2 loop error by ensuring tasks are provided via HTMX
This commit is contained in:
root
2026-03-24 14:21:08 +00:00
parent f426b2c025
commit 2127cc10cd
3 changed files with 66 additions and 76 deletions
+3 -2
View File
@@ -27,14 +27,15 @@ async def get_downloads(
"""Get list of all download tasks. Returns HTML for HTMX."""
tasks = download_manager.get_all_tasks()
# Check for HTMX or explicit HTML request
# Force HTML if requested or via HTMX
if html or request.headers.get("HX-Request"):
print(f"[DOWNLOADS] Returning HTML list for {len(tasks)} tasks")
print(f"[DOWNLOADS] HTMX Request detected. Returning HTML for {len(tasks)} tasks.")
return templates.TemplateResponse(
"components/downloads_list.html",
{"request": request, "tasks": tasks}
)
print(f"[DOWNLOADS] API Request detected. Returning JSON.")
return {"downloads": tasks}