-
Notifications
You must be signed in to change notification settings - Fork 3
/
views.py
39 lines (28 loc) · 1.25 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from fastapi import APIRouter, Depends, Request
from fastapi.responses import HTMLResponse
from lnbits.core.models import User
from lnbits.decorators import check_user_exists
from lnbits.helpers import template_renderer
copilot_generic_router: APIRouter = APIRouter()
def copilot_renderer():
return template_renderer(["copilot/templates"])
@copilot_generic_router.get("/", response_class=HTMLResponse)
async def index(request: Request, user: User = Depends(check_user_exists)):
return copilot_renderer().TemplateResponse(
"copilot/index.html", {"request": request, "user": user.json()}
)
@copilot_generic_router.get("/cp/", response_class=HTMLResponse)
async def compose(request: Request):
return copilot_renderer().TemplateResponse(
"copilot/compose.html", {"request": request}
)
@copilot_generic_router.get("/pn/", response_class=HTMLResponse)
async def panel(request: Request):
return copilot_renderer().TemplateResponse(
"copilot/panel.html", {"request": request}
)
@copilot_generic_router.get("/chat/{chat_id}", response_class=HTMLResponse)
async def chat(request: Request, chat_id):
return copilot_renderer().TemplateResponse(
"copilot/chat.html", {"request": request, "chat_id": chat_id}
)