-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
60 lines (49 loc) · 1.66 KB
/
Copy pathconfig.py
File metadata and controls
60 lines (49 loc) · 1.66 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Configuration file for Family Budget application.
Loads settings from environment variables (via .env file in development).
"""
import os
from dataclasses import dataclass
from dotenv import load_dotenv
# Load environment variables from .env file (development only)
load_dotenv()
@dataclass
# pylint: disable=too-few-public-methods,invalid-name
class Config:
"""Base configuration class."""
# Flask settings
SECRET_KEY: str = os.environ.get('SECRET_KEY') or 'dev-secret-key-change-in-production'
# MongoDB settings
MONGO_URI: str = os.environ.get('MONGO_URI') or 'mongodb://localhost:27017/budget_app'
# Flask-CORS settings
CORS_HEADERS: str = 'Content-Type'
# Application settings
DEBUG: bool = os.environ.get('FLASK_ENV') == 'development'
TESTING: bool = False
@dataclass
# pylint: disable=too-few-public-methods
class DevelopmentConfig(Config):
"""Development environment configuration."""
DEBUG: bool = True
TESTING: bool = False
@dataclass
# pylint: disable=too-few-public-methods
class TestingConfig(Config):
"""Testing environment configuration."""
TESTING: bool = True
MONGO_URI: str = 'mongodb://localhost:27017/budget_app_test'
@dataclass
# pylint: disable=too-few-public-methods
class ProductionConfig(Config):
"""Production environment configuration."""
DEBUG: bool = False
TESTING: bool = False
# In production, SECRET_KEY must be set via an environment variable
SECRET_KEY: str = os.environ.get('SECRET_KEY')
# Configuration dictionary
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}