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

44 lines
1.2 KiB
Python
Raw Normal View History

2022-01-28 16:22:54 +00:00
import asyncio
2022-01-27 12:24:38 +00:00
2022-07-20 11:46:20 +01:00
from fastapi import APIRouter
2022-08-16 12:19:31 +01:00
from starlette.staticfiles import StaticFiles
2022-07-11 21:38:05 +01:00
from lnbits.db import Database
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart
2022-01-28 16:22:54 +00:00
2022-12-20 08:21:48 +00:00
db = Database("ext_shop")
2022-07-20 11:46:20 +01:00
2022-12-20 08:21:48 +00:00
shop_ext: APIRouter = APIRouter(prefix="/shop", tags=["shop"])
2022-07-20 11:46:20 +01:00
2022-12-20 08:21:48 +00:00
shop_static_files = [
2022-07-20 11:46:20 +01:00
{
2022-12-20 08:21:48 +00:00
"path": "/shop/static",
"app": StaticFiles(directory="lnbits/extensions/shop/static"),
"name": "shop_static",
2022-07-20 11:46:20 +01:00
}
]
2022-07-11 21:38:05 +01:00
# if 'nostradmin' not in LNBITS_ADMIN_EXTENSIONS:
2022-12-20 08:21:48 +00:00
# @shop_ext.get("/", response_class=HTMLResponse)
2022-07-11 21:38:05 +01:00
# async def index(request: Request):
# return template_renderer().TemplateResponse(
# "error.html", {"request": request, "err": "Ask system admin to enable NostrAdmin!"}
# )
# else:
2022-07-20 11:46:20 +01:00
2022-08-16 12:19:31 +01:00
2022-12-20 08:21:48 +00:00
def shop_renderer():
return template_renderer(["lnbits/extensions/shop/templates"])
# return template_renderer(["lnbits/extensions/shop/templates"])
2022-02-10 13:54:36 +00:00
2022-07-12 15:25:25 +01:00
2022-07-11 21:38:05 +01:00
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
2022-02-10 13:54:36 +00:00
2022-12-20 08:21:48 +00:00
def shop_start():
2022-07-11 21:38:05 +01:00
loop = asyncio.get_event_loop()
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))