Team Ai
Apppublic

Multimedika/Bot_Development

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py64 linesDownload Raw Back to root
1from fastapi.applications import FastAPI2from api.router import (3    health,4    user,5    trial,6    role,7    book,8    book_collection,9    category,10    bot_general,11    bot_specific,12    bot_one13)14from fastapi.middleware.cors import CORSMiddleware15from api.events import register_events16from utils.utils import pipe17 18 19def create_instance() -> FastAPI:20    return FastAPI()21 22 23def add_middleware(app: FastAPI) -> FastAPI:24    app.add_middleware(25        CORSMiddleware,26        allow_origins=["*"],27        allow_credentials=True,28        allow_methods=["*"],29        allow_headers=["*"],30    )31    return app32 33 34def init_database(app: FastAPI) -> FastAPI:35    return app36 37 38def register_routers(app: FastAPI) -> FastAPI:39    app.include_router(user.router)40    app.include_router(category.router)41    app.include_router(book.router)42    app.include_router(book_collection.router)43    app.include_router(bot_general.router)44    app.include_router(bot_specific.router)45    app.include_router(bot_one.router)46    app.include_router(trial.router) 47    app.include_router(role.router)48    app.include_router(health.router)49 50    return app51 52 53def init_app() -> FastAPI:54    app: FastAPI = pipe(55        create_instance(),56        add_middleware,57        init_database,58        register_events,59        register_routers,60    )61    return app62 63 64app = init_app()