mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 15:15:37 +01:00
New structure
This commit is contained in:
40
src/applications/web_app/app.py
Normal file
40
src/applications/web_app/app.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from core.mongo import mongo_manager
|
||||
from core.redis import redis_manager
|
||||
from core.broker import broker
|
||||
|
||||
from .auth.authx import auth
|
||||
from .views import routes
|
||||
from .utils.static import SPAStaticFiles
|
||||
|
||||
|
||||
def get_app() -> FastAPI:
|
||||
app = FastAPI()
|
||||
|
||||
auth.handle_errors(app)
|
||||
|
||||
for route in routes:
|
||||
app.include_router(route)
|
||||
|
||||
app.mount(
|
||||
"/",
|
||||
SPAStaticFiles(
|
||||
directory="modules/web_app/frontend",
|
||||
html=True
|
||||
),
|
||||
name="frontend"
|
||||
)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
await mongo_manager.init()
|
||||
await redis_manager.init()
|
||||
|
||||
if not broker.is_worker_process:
|
||||
await broker.startup()
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = get_app()
|
||||
Reference in New Issue
Block a user