# -*- coding: utf-8 -*- import logging from pathlib import Path import uvicorn from fastapi import FastAPI from loguru import logger from app.api.routers import targets, equipment, space from app.core.config import settings from app.core.events import create_start_app_handler from app.core.logger import InterceptHandler logging.getLogger().handlers = [InterceptHandler()] logger.add(Path(settings.LOGS_DIR, 'env_fastapi.log'), level='INFO', rotation='00:00', encoding='utf-8') def get_application() -> FastAPI: application = FastAPI(title=settings.PROJECT_NAME) application.add_event_handler('startup', create_start_app_handler()) application.include_router(equipment.router, prefix='/equip', tags=['equipment']) application.include_router(space.router, prefix='/room', tags=['spaces']) application.include_router(targets.router, prefix='/target', tags=['targets']) return application app = get_application() if __name__ == '__main__': uvicorn.run(app, host='0.0.0.0', port=8000)