Spaces:
Sleeping
Sleeping
| """ | |
| Configuration for the PDF Accessibility Pipeline web backend. | |
| Loads from .env in the project root (parent of backend/). | |
| """ | |
| import os | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| # The backend/ directory | |
| _BACKEND_DIR = Path(__file__).resolve().parent | |
| # The project root (pdf-script-web/) | |
| _PROJECT_ROOT = _BACKEND_DIR.parent | |
| # Load .env from project root | |
| load_dotenv(_PROJECT_ROOT / ".env") | |
| def _resolve(env_var: str, default: Path) -> Path: | |
| val = os.environ.get(env_var) | |
| if val: | |
| p = Path(val) | |
| if not p.is_absolute(): | |
| p = (_PROJECT_ROOT / p).resolve() | |
| return p | |
| return default.resolve() | |
| # PIPELINE_DIR: where the pdf-script repo lives | |
| PIPELINE_DIR: Path = _resolve( | |
| "PIPELINE_DIR", | |
| _PROJECT_ROOT.parent / "pdf-script", | |
| ) | |
| # SESSIONS_DIR: temp directory for pipeline sessions | |
| SESSIONS_DIR: Path = _resolve( | |
| "SESSIONS_DIR", | |
| Path("/tmp/pdf-pipeline-sessions"), | |
| ) | |
| # YOLO model path | |
| YOLO_MODEL_PATH: Path = _resolve( | |
| "YOLO_MODEL_PATH", | |
| PIPELINE_DIR / "yolov11x_best.pt", | |
| ) | |
| # Java tagger JAR | |
| JAR_PATH: Path = PIPELINE_DIR / "pdftagger.jar" | |
| # Backend port | |
| BACKEND_PORT: int = int(os.environ.get("BACKEND_PORT", "8000")) | |
| # Google OAuth client ID (from Google Cloud Console) | |
| GOOGLE_CLIENT_ID: str = os.environ.get("GOOGLE_CLIENT_ID", "") | |
| # Secret key for signing JWTs (generate a strong random string for production) | |
| JWT_SECRET: str = os.environ.get("JWT_SECRET", "change-me-in-production") | |
| # SQLite database path | |
| DB_PATH: Path = _resolve("DB_PATH", SESSIONS_DIR / "itagpdf.db") | |