-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
35 lines (26 loc) · 789 Bytes
/
config.py
File metadata and controls
35 lines (26 loc) · 789 Bytes
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
31
32
33
34
35
"""
Configuration management
"""
import os
from pathlib import Path
from typing import Dict, Any
from dotenv import load_dotenv
load_dotenv()
class Config:
"""Application configuration"""
def __init__(self):
self.env = os.getenv('ENV', 'development')
self.debug = os.getenv('DEBUG', 'False').lower() == 'true'
self.log_level = os.getenv('LOG_LEVEL', 'INFO')
def get(self, key: str, default: Any = None) -> Any:
"""Get configuration value"""
return os.getenv(key, default)
def to_dict(self) -> Dict[str, Any]:
"""Convert config to dictionary"""
return {
'env': self.env,
'debug': self.debug,
'log_level': self.log_level
}
# Global config instance
config = Config()