-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathviews.py
More file actions
22 lines (17 loc) · 801 Bytes
/
views.py
File metadata and controls
22 lines (17 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastapi import APIRouter, Depends, Request
from fastapi.responses import HTMLResponse
from lnbits.core.crud.users import get_user_from_account
from lnbits.core.models.users import Account
from lnbits.decorators import check_admin
from lnbits.helpers import template_renderer
nostrclient_generic_router = APIRouter()
def nostr_renderer():
return template_renderer(["nostrclient/templates"])
@nostrclient_generic_router.get("/", response_class=HTMLResponse)
async def index(request: Request, account: Account = Depends(check_admin)):
user = await get_user_from_account(account)
if not user:
return HTMLResponse("No user found", status_code=404)
return nostr_renderer().TemplateResponse(
"nostrclient/index.html", {"request": request, "user": user.json()}
)