internationalscholarsprogram/handbook-engine
0
1"""Application configuration via environment variables."""2 3import os4from functools import lru_cache5from pydantic_settings import BaseSettings6 7 8class Settings(BaseSettings):9 """All config comes from environment variables or .env file."""10 11 # App12 app_name: str = "ISP Handbook Service"13 app_version: str = "1.0.0"14 debug: bool = False15 port: int = 7860 # Hugging Face Spaces default16 17 # External API endpoints (the source-of-truth JSON APIs)18 handbook_general_endpoint: str = ""19 university_handbook_endpoint: str = ""20 api_base_url: str = "https://finsapdev.qhtestingserver.com"21 general_sections_path: str = "/MODEL_APIS/handbook_general_sections.php"22 university_sections_path: str = "/MODEL_APIS/university_handbook.php"23 24 # Images25 images_dir: str = "./images"26 27 # Fonts28 font_dir: str = "./fonts"29 30 # CORS31 cors_origins: str = "http://localhost:5173,http://127.0.0.1:5173,https://finsapdev.qhtestingserver.com,https://internationalscholarsdev.qhtestingserver.com"32 33 # Request timeouts34 http_timeout: int = 2535 36 model_config = {"env_file": ".env", "env_file_encoding": "utf-8", "extra": "ignore"}37 38 @property39 def cors_origins_list(self) -> list[str]:40 return [o.strip() for o in self.cors_origins.split(",") if o.strip()]41 42 @property43 def general_endpoint_url(self) -> str:44 if self.handbook_general_endpoint:45 return self.handbook_general_endpoint46 return self.api_base_url.rstrip("/") + self.general_sections_path47 48 @property49 def university_endpoint_url(self) -> str:50 if self.university_handbook_endpoint:51 return self.university_handbook_endpoint52 return self.api_base_url.rstrip("/") + self.university_sections_path53 54 55@lru_cache()56def get_settings() -> Settings:57 return Settings()58 