Первый коммит
This commit is contained in:
38
app/main.py
Normal file
38
app/main.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core.error_handlers import register_error_handlers
|
||||
from app.modules.application import ModularApplication
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(title="Agent Backend MVP", version="0.1.0")
|
||||
modules = ModularApplication()
|
||||
app.state.modules = modules
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=False,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(modules.chat.public_router())
|
||||
app.include_router(modules.rag.public_router())
|
||||
app.include_router(modules.rag.internal_router())
|
||||
app.include_router(modules.agent.internal_router())
|
||||
|
||||
register_error_handlers(app)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup() -> None:
|
||||
modules.startup()
|
||||
|
||||
@app.get("/health")
|
||||
async def health() -> dict:
|
||||
return {"status": "ok"}
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user