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

45 lines
1 KiB
Python
Raw Normal View History

2021-10-12 20:24:00 +01:00
import asyncio
from fastapi import APIRouter, FastAPI
from fastapi.staticfiles import StaticFiles
from starlette.routing import Mount
2021-10-12 19:54:35 +01:00
from lnbits.db import Database
2021-10-12 20:24:00 +01:00
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart
2021-10-12 19:54:35 +01:00
db = Database("ext_copilot")
2021-10-12 20:24:00 +01:00
copilot_static_files = [
{
"path": "/copilot/static",
"app": StaticFiles(directory="lnbits/extensions/copilot/static"),
"name": "copilot_static",
}
]
copilot_ext: APIRouter = APIRouter(
prefix="/copilot",
tags=["copilot"]
# "lnurlp", __name__, static_folder="static", template_folder="templates"
2021-10-12 19:54:35 +01:00
)
2021-10-12 20:24:00 +01:00
def copilot_renderer():
return template_renderer(
[
"lnbits/extensions/copilot/templates",
]
)
2021-10-12 19:54:35 +01:00
from .views_api import * # noqa
from .views import * # noqa
2021-10-12 20:24:00 +01:00
from .tasks import wait_for_paid_invoices
2021-10-12 19:54:35 +01:00
from .lnurl import * # noqa
2021-10-12 20:24:00 +01:00
def copilot_start():
loop = asyncio.get_event_loop()
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))