""" Created By: ishwor subedi Date: 2024-07-31 """ import uvicorn from fastapi import FastAPI, Depends from fastapi.middleware.cors import CORSMiddleware from src import logging as logger from src.api.conversai_api import conversai_api_router from src.api.speech_api import speech_translator_router from src.api.user_management_api import user_management_api_router from src.utils.utils import load_ini_config from src.api.analytics_api import analytic_endpoints_router from src.api.jwt_bearer import access_check_bearer logger.info("---------------------------> Starting FastAPI Server <---------------------------") 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)] logger.info("---------------------------> FastAPI Server Started <---------------------------") app.add_middleware( CORSMiddleware, allow_origins=["*"], # Allow access from all sources allow_credentials=True, allow_methods=["*"], # Allow all HTTP methods allow_headers=["*"], # Allow all request headers ) app.include_router(user_management_api_router, prefix="/conversai") logger.info("---------------------------> User Management API Started <---------------------------") app.include_router(conversai_api_router, prefix="/conversai") logger.info("---------------------------> ConversAI API Started <---------------------------") app.include_router(speech_translator_router, prefix="/conversai", dependencies=PROTECTED) logger.info("---------------------------> Speech Translator API Started <---------------------------") app.include_router(analytic_endpoints_router, prefix="/conversai", dependencies=PROTECTED) logger.info("---------------------------> Analytics API Started <---------------------------") if __name__ == '__main__': uvicorn.run(app, port=int(config.get('fastapi_config', 'port')), host=config.get('fastapi_config', 'host'), timeout_keep_alive=300, timeout_graceful_shutdown=600)