Spaces:
Sleeping
Sleeping
File size: 904 Bytes
a317be6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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)
@app.get("/")
async def root():
"""Health check endpoint."""
return {"message": "PDF Merger API is running"}
|