Spaces:
Sleeping
Sleeping
Download server/base_codebase/src/services/config_service.py from arikatokachi/safe_code_env: direct link, hf CLI and curl.
- Browser
- Download file 974 Bytes
-
https://huggingface.co/spaces/arikatokachi/safe_code_env/resolve/main/server/base_codebase/src/services/config_service.py
- Command line
-
hf download hf://spaces/arikatokachi/safe_code_env/server/base_codebase/src/services/config_service.py
-
curl -L -o config_service.py https://huggingface.co/spaces/arikatokachi/safe_code_env/resolve/main/server/base_codebase/src/services/config_service.py
974 Bytes
| """Configuration service with proper secrets management using environment variables.""" | |
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| # Load environment variables from .env file | |
| from dotenv import load_dotenv | |
| # Get the directory containing this file and look for .env nearby | |
| _env_path = Path(__file__).parent.parent.parent / ".env" | |
| if _env_path.exists(): | |
| load_dotenv(_env_path) | |
| def get_api_key() -> str: | |
| """Get API key from environment variable, not hardcoded.""" | |
| return os.environ.get("API_KEY", "") | |
| def get_database_url() -> str: | |
| """Get database URL from environment variable, not hardcoded.""" | |
| return os.environ.get("DATABASE_URL", "") | |
| def get_secret_key() -> str: | |
| """Get secret key from environment variable, not hardcoded.""" | |
| return os.environ.get("SECRET_KEY", "") | |
| def is_production() -> bool: | |
| """Check if running in production mode.""" | |
| return os.environ.get("ENV", "development") == "production" | |