Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| import os | |
| from backend.app.routes import users_route, events_route, travels_route | |
| import asyncio | |
| from backend.app.tasks.worker_tasks import run_embedding_worker_loop | |
| # avoiding the conflictions | |
| os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE' | |
| app = FastAPI() | |
| async def startup_event(): | |
| print("Application startup...") | |
| # Schedule the background task for embedding worker loop | |
| asyncio.create_task(run_embedding_worker_loop(interval_seconds=30)) | |
| async def shutdown_event(): | |
| print("Application shutdown...") | |
| users_route.user_db.db.close() | |
| events_route.event_db.db.close() | |
| travels_route.travel_db.db.close() | |
| # Include routers | |
| app.include_router(events_route.router, prefix="/events", tags=["events"]) | |
| app.include_router(travels_route.router, prefix="/travels", tags=["travels"]) | |
| app.include_router(users_route.router, prefix="/users", tags=["users"]) | |