Spaces:
Sleeping
Sleeping
File size: 1,167 Bytes
9002555 0743bb0 9002555 d075fb6 9002555 0743bb0 9002555 d075fb6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
from fastapi.applications import FastAPI
from api.router import health, topic, user, bot, trial, role, reader
from fastapi.middleware.cors import CORSMiddleware
from api.events import register_events
from utils.utils import pipe
import uvicorn
def create_instance() -> FastAPI:
return FastAPI()
def add_middleware(app: FastAPI) -> FastAPI:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
return app
def init_database(app: FastAPI) -> FastAPI:
return app
def register_routers(app: FastAPI) -> FastAPI:
app.include_router(user.router)
app.include_router(topic.router)
app.include_router(bot.router)
app.include_router(trial.router)
app.include_router(role.router)
app.include_router(reader.router)
app.include_router(health.router)
return app
def init_app() -> FastAPI:
app: FastAPI = pipe(
create_instance(), add_middleware, init_database, register_events, register_routers
)
return app
app = init_app()
if __name__ == '__main__':
uvicorn.run(app, loop = 'asyncio') |