diff --git a/app/main.py b/app/main.py index fbb3730..25dcba0 100644 --- a/app/main.py +++ b/app/main.py @@ -35,4 +35,6 @@ async def unauthorized_redirect_handler(request: Request, exc: Exception): if __name__ == "__main__": + print("Save") + print ("This is ") uvicorn.run("app.main:app", host=get_settings().app_host, port=get_settings().app_port, reload=get_settings().env.lower()!="production") diff --git a/app/routers/app.py b/app/routers/app.py index 28236fe..3e30d86 100644 --- a/app/routers/app.py +++ b/app/routers/app.py @@ -23,4 +23,20 @@ async def app( context={ "user": user } + ) + +@app_router.get("/todos", response_class=HTMLResponse) +async def get_todos( + request: Request, + user: AuthDep, #get currently logged in user + db:SessionDep +): + todos = db.exec(select(Todo).where(Todo).user_id == user.id).all() + return templates.TemplateResponse( + request=request, + name="todos.html", + context={ + "user":user, + "todos":todos + } ) \ No newline at end of file diff --git a/app/templates/authenticated-base.html b/app/templates/authenticated-base.html index a3d569a..434eff0 100644 --- a/app/templates/authenticated-base.html +++ b/app/templates/authenticated-base.html @@ -79,9 +79,13 @@
| ID | +Todo task | +
|---|---|
| {{todo.id}} | +{{todo.title}} | +
No Todos found.
+ +{% endif %} + +{% endblock %} \ No newline at end of file