heroweb/lib/webcomponents/timeline/controller.py

22 lines
743 B
Python
Raw Normal View History

2024-09-11 19:19:48 +00:00
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse
from jinja2 import TemplateNotFound
from webcomponents.timeline_white.web import render as render_timeline
router_timeline = APIRouter()
@router_timeline.get('/timeline/{id:int}', response_class=HTMLResponse)
async def timeline_example(request: Request, id: int):
# deps = request.app.deps
try:
return render_timeline()
except TemplateNotFound:
raise HTTPException(
status_code=404, detail=f'Template not found: {template_path}'
) from None
except Exception as e:
raise HTTPException(
status_code=500, detail=f'An unexpected error occurred: {str(e)}'
) from None