You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from broadcaster import Broadcast
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
|
|
from project.config import settings
|
|
|
|
|
|
|
|
broadcast = Broadcast(settings.WS_MESSAGE_QUEUE)
|
|
|
|
|
|
|
|
# Event Hooks
|
|
|
|
async def startup_event():
|
|
|
|
await broadcast.connect()
|
|
|
|
|
|
|
|
|
|
|
|
async def shutdown_event():
|
|
|
|
await broadcast.disconnect()
|
|
|
|
|
|
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
|
|
# Starlette discourages decorator syntax now for eventhooks
|
|
|
|
app = FastAPI(on_startup=[startup_event], on_shutdown=[shutdown_event])
|
|
|
|
|
|
|
|
# do this before loading routes
|
|
|
|
from project.celery_utils import create_celery
|
|
|
|
|
|
|
|
app.celery_app = create_celery()
|
|
|
|
|
|
|
|
from .users import users_router
|
|
|
|
|
|
|
|
app.include_router(users_router)
|
|
|
|
|
|
|
|
from project.ws import ws_router
|
|
|
|
|
|
|
|
app.include_router(ws_router)
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
|
async def root():
|
|
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
|
|
return app
|