12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- # -*- coding: utf-8 -*-
- import logging
- from pathlib import Path
- import uvicorn
- from fastapi import FastAPI
- from loguru import logger
- from app.api.routers import algorithms, targets, equipment, space, item, user, bluetooth, devices, nlp, positioning
- from app.api.routers.model_path import early_start
- from app.core.config import settings
- from app.core.events import create_start_app_handler
- from app.core.logger import InterceptHandler
- from app.db.session import Base, engine
- Base.metadata.create_all(bind=engine)
- 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, root_path='/env-py')
- application.add_event_handler('startup', create_start_app_handler())
- application.include_router(algorithms.router, prefix='/algo', tags=['Algorithms'])
- application.include_router(bluetooth.router, prefix='/bluetooth', tags=['BLE'])
- application.include_router(devices.router, prefix='/devices', tags=['Devices'])
- application.include_router(early_start.router, prefix='/model-path', tags=['Model Path'])
- application.include_router(equipment.router, prefix='/equip', tags=['Equipment'])
- application.include_router(item.router, prefix='/items', tags=['Items'])
- application.include_router(nlp.router, prefix='/nlp-service', tags=['NLP'])
- application.include_router(positioning.router, prefix='/positioning-service', tags=['Positioning Service'])
- application.include_router(space.router, prefix='/room', tags=['Spaces'])
- application.include_router(targets.router, prefix='/target', tags=['Targets'])
- application.include_router(user.router, prefix='/users', tags=['Users'])
- return application
- app = get_application()
- if __name__ == '__main__':
- uvicorn.run(app, host='0.0.0.0', port=8000)
|