fix(admin): add missing article_stats route, 500 handler, dev debug mode
- Add /admin/articles/stats HTMX partial endpoint that was referenced by article_stats.html but never created (caused 500 during generation) - Add @app.errorhandler(500) to log exceptions with traceback - Switch dev_run.sh from Granian to Quart debug mode for browser tracebacks and auto-reload Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -165,7 +165,7 @@ echo ""
|
||||
echo "Press Ctrl-C to stop all processes."
|
||||
echo ""
|
||||
|
||||
run_with_label "$COLOR_APP" "app " uv run granian --interface asgi --host 127.0.0.1 --port 5000 --reload --reload-paths web/src padelnomics.app:app
|
||||
run_with_label "$COLOR_APP" "app " uv run python -m padelnomics.app
|
||||
run_with_label "$COLOR_WORKER" "worker" uv run python -u -m padelnomics.worker
|
||||
run_with_label "$COLOR_CSS" "css " make css-watch
|
||||
|
||||
|
||||
@@ -2465,6 +2465,18 @@ async def articles():
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/articles/stats")
|
||||
@role_required("admin")
|
||||
async def article_stats():
|
||||
"""HTMX partial: article stats bar (polled while generating)."""
|
||||
stats = await _get_article_stats()
|
||||
return await render_template(
|
||||
"admin/partials/article_stats.html",
|
||||
stats=stats,
|
||||
is_generating=await _is_generating(),
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/articles/results")
|
||||
@role_required("admin")
|
||||
async def article_results():
|
||||
|
||||
@@ -270,6 +270,13 @@ def create_app() -> Quart:
|
||||
from .sitemap import sitemap_response
|
||||
return await sitemap_response(config.BASE_URL)
|
||||
|
||||
# Ensure unhandled exceptions are always logged (Granian doesn't show
|
||||
# Quart's debug error page, so without this 500s are silent).
|
||||
@app.errorhandler(500)
|
||||
async def handle_500(error):
|
||||
app.logger.exception("Unhandled 500 error: %s", error)
|
||||
return "Internal Server Error", 500
|
||||
|
||||
# Health check
|
||||
@app.route("/health")
|
||||
async def health():
|
||||
|
||||
Reference in New Issue
Block a user