Converted views

This commit is contained in:
Ben Arc
2021-08-21 01:55:07 +01:00
parent d3d24abb17
commit bbdb96f4ac
21 changed files with 177 additions and 112 deletions
+7 -4
View File
@@ -5,19 +5,22 @@ from lnbits.decorators import check_user_exists, validate_uuids
from . import tpos_ext
from .crud import get_tpos
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates")
@tpos_ext.get("/")
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
return await render_template("tpos/index.html", user=g.user)
async def index(request: Request):
return await templates.TemplateResponse("tpos/index.html", {"request":request,"user":g.user})
@tpos_ext.get("/{tpos_id}")
async def tpos(tpos_id):
async def tpos(request: Request, tpos_id):
tpos = await get_tpos(tpos_id)
if not tpos:
abort(HTTPStatus.NOT_FOUND, "TPoS does not exist.")
return await render_template("tpos/tpos.html", tpos=tpos)
return await templates.TemplateResponse("tpos/tpos.html", {"request":request,"tpos":tpos})