Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from .config import get_settings | |
| from .database import connect_to_mongo, close_mongo_connection | |
| from .routers import auth, pdf | |
| settings = get_settings() | |
| app = FastAPI( | |
| title="PDF Merger API", | |
| description="Backend API for merging PDF files with authentication", | |
| version="1.0.0" | |
| ) | |
| # CORS Middleware | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # In production, specify exact origins | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Event Handlers | |
| app.add_event_handler("startup", connect_to_mongo) | |
| app.add_event_handler("shutdown", close_mongo_connection) | |
| # Include Routers | |
| app.include_router(auth.router) | |
| app.include_router(pdf.router) | |
| async def root(): | |
| """Health check endpoint.""" | |
| return {"message": "PDF Merger API is running"} | |