|
|
|
import uvicorn |
|
from fastapi import FastAPI, Depends |
|
from fastapi.middleware.cors import CORSMiddleware |
|
from core import logging as logger |
|
from core.api.chatai import chatai_api_router |
|
from core.api.jwt_bearer import access_check_bearer |
|
from core.api.user_management_api import user_management_api_router |
|
from core.utils.utils import load_ini_config |
|
config = load_ini_config("config.ini") |
|
app = FastAPI(docs_url=config.get('fastapi_config', 'docs_url'), redoc_url=config.get('fastapi_config', 'redoc_url'), |
|
openapi_url=config.get('fastapi_config', 'openapi_url') |
|
) |
|
|
|
PROTECTED = [Depends(access_check_bearer)] |
|
app.add_middleware( |
|
CORSMiddleware, |
|
allow_origins=["*"], |
|
allow_credentials=True, |
|
allow_methods=["*"], |
|
allow_headers=["*"], |
|
) |
|
app.include_router(user_management_api_router, prefix="/chatai") |
|
app.include_router(chatai_api_router, prefix="/chatai") |
|
if __name__ == '__main__': |
|
uvicorn.run(app, port=config.get("fastapi_config", "port"), host=config.get('fastapi_config', 'host'), |
|
timeout_keep_alive=300, timeout_graceful_shutdown=600) |
|
|