How to navigate through FastAPI routes by clicking on HTML button in Jinja2 Templates?
Backend Your /tasks endpoint (i.e., find_all_tasks function) should return a new Jinja2 TemplateResponse with the list of tasks. For instance: @app.get(‘/tasks’) def find_all_tasks(request: Request): tasks = [‘task 1’, ‘task 2’, ‘task 3’] return templates.TemplateResponse(“tasks.html”, {“request”: request, ‘tasks’: tasks}) Frontend 1. Click on the URL to get to the tasks page In index.html, you can use … Read more