lnbits-legend/lnbits/extensions/nostradmin/__init__.py

38 lines
933 B
Python
Raw Normal View History

2022-02-10 13:54:36 +00:00
from fastapi import APIRouter, Request
2022-02-07 13:22:43 +00:00
from lnbits.db import Database
from lnbits.helpers import template_renderer
2022-02-10 13:54:36 +00:00
from starlette.exceptions import HTTPException
from starlette.responses import HTMLResponse
from http import HTTPStatus
from lnbits.settings import LNBITS_ADMIN_EXTENSIONS
2022-02-07 13:22:43 +00:00
2022-02-08 13:13:36 +00:00
nostradmin_ext: APIRouter = APIRouter(prefix="/nostradmin", tags=["nostradmin"])
2022-02-07 13:22:43 +00:00
2022-02-10 13:54:36 +00:00
db = Database("ext_nostradmin")
if 'nostradmin' not in LNBITS_ADMIN_EXTENSIONS:
@nostradmin_ext.get("/", response_class=HTMLResponse)
async def index(request: Request):
return template_renderer().TemplateResponse(
"error.html", {"request": request, "err": "NostrAdmin must be added to LNBITS_ADMIN_EXTENSIONS in .env"}
)
else:
def nostr_renderer():
return template_renderer(["lnbits/extensions/nostradmin/templates"])
from .views import * # noqa
from .views_api import * # noqa
2022-02-07 13:22:43 +00:00
2022-02-08 10:35:20 +00:00
2022-02-07 13:22:43 +00:00