File size: 771 Bytes
b657fcc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """Configuration helpers."""
import os
from typing import Optional
try:
from dotenv import load_dotenv
load_dotenv()
except Exception:
pass
def get_env(key: str, default: Optional[str] = None) -> Optional[str]:
return os.environ.get(key, default)
import os
try:
from dotenv import load_dotenv
load_dotenv()
except Exception:
# If python-dotenv isn't installed, continue with environment variables or defaults
try:
# If there's a local shim, call it
from dotenv import load_dotenv as _ld
_ld()
except Exception:
pass
# Default to an in-memory SQLite DB for tests/local development when DB_URL is not set
DB_URL = os.getenv('DB_URL') or 'sqlite:///:memory:'
SECRET_KEY = os.getenv('SECRET_KEY') or 'dev-secret'
|