Spaces:
Build error
Build error
| """ | |
| Main FastAPI application entry point. | |
| """ | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.staticfiles import StaticFiles | |
| from fastapi.responses import FileResponse | |
| from app.api import router | |
| from app.config import settings | |
| from app.utils.logging import setup_logging | |
| # Setup logging | |
| setup_logging() | |
| # Create FastAPI app | |
| app = FastAPI( | |
| title=settings.app_name, | |
| version=settings.app_version, | |
| description="API for extracting data from Canadian T1 tax return PDFs and filling target PDF forms.", | |
| docs_url="/docs", | |
| redoc_url="/redoc" | |
| ) | |
| # CORS middleware for frontend | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Include API routes | |
| app.include_router(router) | |
| # Mount static files | |
| app.mount("/static", StaticFiles(directory=str(settings.static_dir)), name="static") | |
| async def root(): | |
| """Serve the main frontend page.""" | |
| return FileResponse(settings.templates_dir / "index.html") | |
| async def favicon(): | |
| """Serve favicon.""" | |
| favicon_path = settings.static_dir / "favicon.ico" | |
| if favicon_path.exists(): | |
| return FileResponse(favicon_path) | |
| return {"detail": "Not found"} | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run( | |
| "app.main:app", | |
| host="0.0.0.0", | |
| port=8000, | |
| reload=settings.debug | |
| ) | |