Spaces:
Sleeping
Sleeping
Download doc_intelligence/src/config.py from vettri06/Document_intelligence: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/spaces/vettri06/Document_intelligence/resolve/main/doc_intelligence/src/config.py
- Command line
-
hf download hf://spaces/vettri06/Document_intelligence/doc_intelligence/src/config.py
-
curl -L -o config.py https://huggingface.co/spaces/vettri06/Document_intelligence/resolve/main/doc_intelligence/src/config.py
855 Bytes
| """Configuration for local development and hosted deployments.""" | |
| import os | |
| from pathlib import Path | |
| from typing import Optional | |
| from dotenv import load_dotenv | |
| _PROJECT_ROOT = Path(__file__).resolve().parents[1] | |
| _LOCAL_ENV_FILES = (_PROJECT_ROOT / ".env", _PROJECT_ROOT.parent / ".env") | |
| def load_local_environment() -> None: | |
| """Load ignored local dotenv files without overriding environment variables.""" | |
| for env_file in _LOCAL_ENV_FILES: | |
| if env_file.is_file(): | |
| load_dotenv(env_file, override=False) | |
| def get_secret(*names: str, default: Optional[str] = None) -> Optional[str]: | |
| """Return the first configured secret, normalized and never logged.""" | |
| load_local_environment() | |
| for name in names: | |
| value = os.getenv(name) | |
| if value: | |
| return value.strip().strip("'\"") | |
| return default | |