lnbits-legend/lnbits/extensions/admin/views.py

32 lines
865 B
Python
Raw Normal View History

2022-03-12 14:18:09 +00:00
from email.policy import default
from os import getenv
2022-03-07 05:03:32 +00:00
2022-03-12 14:18:09 +00:00
from fastapi import Request
from fastapi.params import Depends
from fastapi.templating import Jinja2Templates
from starlette.responses import HTMLResponse
from lnbits.core.models import User
2022-10-03 16:36:14 +02:00
from lnbits.decorators import check_admin
2022-03-12 14:18:09 +00:00
from lnbits.requestvars import g
2022-10-03 16:36:14 +02:00
from lnbits.settings import WALLET, settings
2022-03-12 14:18:09 +00:00
from . import admin_ext, admin_renderer
2022-03-07 05:03:32 +00:00
2022-03-12 14:18:09 +00:00
templates = Jinja2Templates(directory="templates")
2022-03-07 05:03:32 +00:00
2022-07-05 16:25:02 +01:00
2022-03-12 14:18:09 +00:00
@admin_ext.get("/", response_class=HTMLResponse)
2022-10-03 16:36:14 +02:00
async def index(request: Request, user: User = Depends(check_admin)):
error, balance = await WALLET.status()
2022-07-05 16:25:02 +01:00
2022-03-12 14:18:09 +00:00
return admin_renderer().TemplateResponse(
2022-07-05 16:25:02 +01:00
"admin/index.html",
{
2022-03-12 14:18:09 +00:00
"request": request,
"user": user.dict(),
2022-10-03 16:36:14 +02:00
"settings": settings.dict(),
2022-07-05 16:25:02 +01:00
"balance": balance,
},
2022-03-12 14:18:09 +00:00
)