Add 404 page and Web UI section to README

- Add styled 404 page for HTML requests (returns JSON for API calls)
- Add Web UI section to README documenting available routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-09 10:42:44 +00:00
parent 0a0dd278fe
commit 0f01d8e12c
2 changed files with 31 additions and 0 deletions

View File

@@ -89,6 +89,23 @@ app = FastAPI(
)
@app.exception_handler(404)
async def not_found_handler(request: Request, exc):
"""Custom 404 page."""
accept = request.headers.get("accept", "")
if "text/html" in accept and "application/json" not in accept:
content = '''
<div class="text-center py-16">
<h2 class="text-6xl font-bold text-gray-600 mb-4">404</h2>
<p class="text-xl text-gray-400 mb-8">Page not found</p>
<a href="/" class="text-blue-400 hover:text-blue-300">Go to home page</a>
</div>
'''
username = get_user_from_cookie(request)
return HTMLResponse(base_html("Not Found", content, username), status_code=404)
return JSONResponse({"detail": "Not found"}, status_code=404)
# ============ Data Models ============
class Asset(BaseModel):