| """Application configuration via environment variables."""
|
|
|
| from __future__ import annotations
|
|
|
| import os
|
| from functools import lru_cache
|
| from pydantic_settings import BaseSettings
|
|
|
|
|
| class Settings(BaseSettings):
|
| """All config comes from environment variables or .env file."""
|
|
|
|
|
| app_name: str = "ISP Handbook OCR Engine"
|
| app_version: str = "1.0.0"
|
| debug: bool = False
|
| port: int = 7860
|
|
|
|
|
| max_upload_bytes: int = 100 * 1024 * 1024
|
| upload_dir: str = "/tmp/handbook_uploads"
|
| export_dir: str = "/tmp/handbook_exports"
|
|
|
|
|
| tesseract_cmd: str = ""
|
| ocr_dpi: int = 300
|
| ocr_language: str = "eng"
|
| ocr_timeout_seconds: int = 300
|
|
|
|
|
| api_base_url: str = "https://finsapdev.qhtestingserver.com"
|
| handbook_import_path: str = "/MODEL_APIS/handbook_import_export.php"
|
|
|
|
|
| cors_origins: str = (
|
| "http://localhost:5173,http://localhost:5174,"
|
| "http://127.0.0.1:5173,http://127.0.0.1:5174,"
|
| "https://finsapdev.qhtestingserver.com,"
|
| "https://internationalscholarsdev.qhtestingserver.com"
|
| )
|
|
|
| model_config = {
|
| "env_file": ".env",
|
| "env_file_encoding": "utf-8",
|
| "extra": "ignore",
|
| }
|
|
|
| @property
|
| def cors_origins_list(self) -> list[str]:
|
| return [o.strip() for o in self.cors_origins.split(",") if o.strip()]
|
|
|
| @property
|
| def handbook_import_url(self) -> str:
|
| return self.api_base_url.rstrip("/") + self.handbook_import_path
|
|
|
|
|
| @lru_cache()
|
| def get_settings() -> Settings:
|
| return Settings()
|
|
|