Spaces:
Running
Running
from fastapi import FastAPI, Request | |
from fastapi.staticfiles import StaticFiles | |
from app.api.routes import router | |
import os | |
import logging | |
from dotenv import load_dotenv | |
logging.basicConfig(level=logging.INFO) | |
app = FastAPI(title="Cover Letter Generator") | |
load_dotenv() | |
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
# Serve resumes (these are static, bundled in repo, read-only is fine) | |
app.mount( | |
"/resumes", | |
StaticFiles(directory=os.path.join(BASE_DIR, "static/resumes")), | |
name="resumes" | |
) | |
# Writable directory for PDFs | |
PDF_DIR = "/tmp/pdfs" | |
os.makedirs(PDF_DIR, exist_ok=True) | |
# Serve PDFs (generated at runtime) under /static/pdfs | |
app.mount("/static/pdfs", StaticFiles(directory=PDF_DIR), name="pdfs") | |
async def log_requests(request: Request, call_next): | |
logging.info(f"API hit: {request.method} {request.url}") | |
response = await call_next(request) | |
return response | |
def ping(): | |
return {"status": "ok"} | |
# Register routes | |
app.include_router(router) | |