Spaces:
Sleeping
Sleeping
File size: 1,800 Bytes
c8f4a46 1916431 c8f4a46 | 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 38 39 40 41 42 43 44 45 46 47 48 49 | from contextlib import asynccontextmanager
from typing import AsyncIterator
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import health, resume, analysis
from app.core.config import settings
from app.core.logging import setup_logging
setup_logging()
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
"""Startup / shutdown hook."""
# Ensure upload directory exists (config.py also does this at import time,
# but this is the canonical place for startup side-effects).
settings.upload_dir.mkdir(parents=True, exist_ok=True)
yield
app = FastAPI(
title="AI Resume Reviewer API",
description=(
"Hybrid ATS-style resume analysis: rules + embeddings + LLM. "
"Phase 0/1 β ingestion and extraction only."
),
version="0.1.0",
lifespan=lifespan,
)
# ββ CORS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Allow the Vite dev server (8081) and any localhost variant during development.
# In production, lock this to your actual frontend domain.
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["X-Session-Id"],
)
# ββ Routers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
app.include_router(health.router, prefix="/api")
app.include_router(resume.router, prefix="/api")
app.include_router(analysis.router, prefix="/api")
|