Spaces:
Sleeping
Sleeping
| import os | |
| from dotenv import load_dotenv | |
| # Load .env if present (local dev convenience) | |
| load_dotenv() | |
| APP_TITLE = "PlanMate" | |
| APP_TAGLINE = "AI Powered smart trip planner" | |
| THEME = { | |
| "bg": "#fcfcfc", | |
| "text": "#383838", | |
| "label": "#153d15", | |
| "border": "#153d15", | |
| } | |
| CURRENCY = "PKR" | |
| UNITS = "metric" | |
| LANGUAGE = "en" | |
| # API Base URLs | |
| AMADEUS_BASE = "https://test.api.amadeus.com" | |
| OPENWEATHER_BASE = "https://api.openweathermap.org" | |
| OPENTRIPMAP_BASE = "https://api.opentripmap.com/0.1/en" | |
| # ---------- Hugging Face Secrets Configuration ---------- | |
| def get_secret(key, default=None): | |
| """ | |
| Get secret from Hugging Face Spaces environment or fallback to local .env | |
| """ | |
| # Try to get from environment first (Hugging Face Spaces) | |
| value = os.getenv(key) | |
| if value is None and default is not None: | |
| return default | |
| elif value is None: | |
| st.error(f"Missing required secret: {key}") | |
| st.info("Please add this secret in your Hugging Face Space settings.") | |
| st.stop() | |
| return value | |
| def get_env(key: str) -> str: | |
| val = os.getenv(key) | |
| if not val: | |
| raise RuntimeError(f"Missing required environment variable: {key}") | |
| return val | |
| def get_gemini_key(): | |
| return get_secret("GEMINI_API_KEY") | |
| def get_amadeus_credentials(): | |
| return get_secret("AMADEUS_CLIENT_ID"), get_secret("AMADEUS_CLIENT_SECRET") | |
| def get_openweather_key(): | |
| return get_secret("OPENWEATHER_API_KEY") | |
| def get_opentripmap_key(): | |
| return get_secret("OPENTRIPMAP_API_KEY") | |