File size: 1,038 Bytes
c7bd3fe
 
 
 
 
a704218
 
c7bd3fe
 
 
a704218
c7bd3fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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():
    return {"status": "ok"}


# Register routes
app.include_router(router)