Resume-Parser / app /main.py
SyedAzlanzar
@refactor : update resume parsing and PDF generation logic; improve error handling and file upload process
a704218
raw
history blame
1.05 kB
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")
@app.middleware("http")
async def log_requests(request: Request, call_next):
logging.info(f"API hit: {request.method} {request.url}")
response = await call_next(request)
return response
@app.get("/")
def ping():
print()
return {"status": "ok"}
# Register routes
app.include_router(router)