2021-10-14 11:45:30 +01:00
|
|
|
from http import HTTPStatus
|
2021-10-14 22:30:47 +01:00
|
|
|
from starlette.exceptions import HTTPException
|
|
|
|
from starlette.responses import HTMLResponse
|
|
|
|
from starlette.requests import Request
|
|
|
|
from fastapi.params import Depends
|
2021-10-14 11:45:30 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
from lnbits.core.models import User
|
|
|
|
from lnbits.decorators import check_user_exists
|
2021-10-14 11:45:30 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
from . import watchonly_ext, watchonly_renderer
|
2021-10-17 18:33:29 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
# from .crud import get_payment
|
2021-10-14 11:45:30 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
from fastapi.templating import Jinja2Templates
|
2021-10-14 11:45:30 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
templates = Jinja2Templates(directory="templates")
|
2021-10-14 11:45:30 +01:00
|
|
|
|
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
@watchonly_ext.get("/", response_class=HTMLResponse)
|
|
|
|
async def index(request: Request, user: User = Depends(check_user_exists)):
|
2021-10-17 18:33:29 +01:00
|
|
|
return watchonly_renderer().TemplateResponse(
|
|
|
|
"watchonly/index.html", {"request": request, "user": user.dict()}
|
|
|
|
)
|
2021-10-14 11:45:30 +01:00
|
|
|
|
2021-10-14 22:30:47 +01:00
|
|
|
|
|
|
|
# @watchonly_ext.get("/{charge_id}", response_class=HTMLResponse)
|
|
|
|
# async def display(request: Request, charge_id):
|
|
|
|
# link = get_payment(charge_id)
|
|
|
|
# if not link:
|
|
|
|
# raise HTTPException(
|
|
|
|
# status_code=HTTPStatus.NOT_FOUND,
|
|
|
|
# detail="Charge link does not exist."
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# return watchonly_renderer().TemplateResponse("watchonly/display.html", {"request": request,"link": link.dict()})
|