2021-10-26 22:50:29 +01:00
|
|
|
from fastapi import Request
|
|
|
|
from fastapi.params import Depends
|
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
from starlette.responses import HTMLResponse
|
2021-10-26 16:48:04 +01:00
|
|
|
|
2021-10-26 22:50:29 +01:00
|
|
|
from lnbits.core.models import User
|
|
|
|
from lnbits.decorators import check_user_exists
|
|
|
|
|
|
|
|
from . import bleskomat_ext, bleskomat_renderer
|
2021-10-26 16:48:04 +01:00
|
|
|
from .exchange_rates import exchange_rate_providers_serializable, fiat_currencies
|
|
|
|
from .helpers import get_callback_url
|
|
|
|
|
2021-10-27 12:01:45 +01:00
|
|
|
templates = Jinja2Templates(directory="templates")
|
|
|
|
|
2021-10-26 16:48:04 +01:00
|
|
|
|
2021-10-26 22:50:29 +01:00
|
|
|
@bleskomat_ext.get("/", response_class=HTMLResponse)
|
2021-11-12 02:57:31 -05:00
|
|
|
async def index(req: Request, user: User = Depends(check_user_exists)):
|
2021-10-26 16:48:04 +01:00
|
|
|
bleskomat_vars = {
|
2021-11-12 02:57:31 -05:00
|
|
|
"callback_url": get_callback_url(req),
|
2021-10-26 16:48:04 +01:00
|
|
|
"exchange_rate_providers": exchange_rate_providers_serializable,
|
|
|
|
"fiat_currencies": fiat_currencies,
|
|
|
|
}
|
2021-10-26 22:50:29 +01:00
|
|
|
return bleskomat_renderer().TemplateResponse(
|
2021-11-12 04:14:55 +00:00
|
|
|
"bleskomat/index.html",
|
2021-11-12 02:57:31 -05:00
|
|
|
{"request": req, "user": user.dict(), "bleskomat_vars": bleskomat_vars},
|
2021-10-26 16:48:04 +01:00
|
|
|
)
|