-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
104 lines (77 loc) · 3.1 KB
/
config.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import logging
import os
from datetime import timedelta
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
"""
You can put global variable config for all-enviroment
"""
# Logging Severity Level
LOGGING_LEVEL = logging.INFO
SECRET_KEY = os.environ.get('GLOBAL_SECRET_KEY') or 'GlobalSecretKey123'
# Initial refresh token set for 1 week * 4.
USER_TOKEN_EXPIRED = 604800 * 4
DEBUG = False
# Rate limiting
RATELIMIT_DEFAULT = "200 per day"
RATELIMIT_STORAGE_URL = "memory://"
# JWT Settings
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY', 'jwt-secret-string')
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=1)
class DevelopmentConfig(Config):
"""
Only applied when using Development Configuration
"""
DEBUG = True
# You can load from environment variables, if failed load `default` setting.
SECRET_KEY = os.environ.get('DevServer_SECRET_KEY') or 'DevServerSecretKey123'
# Database SQLAlchemy Configuration
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL',
'postgresql://postgres:postgres'
'@localhost:5432/flask_marketplace')
# Enable Write/Reading on Master/Slave DB servers
SQLALCHEMY_BINDS = {
'master': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace',
'read': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace'
}
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_POOL_SIZE = 10
SQLALCHEMY_MAX_OVERFLOW = 15
class TestingConfig(Config):
"""
Only applied when running Test
"""
DEBUG = True
TESTING = True
SECRET_KEY = 'TestSecretKey123'
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL',
'postgresql://postgres:postgres'
'@localhost:5432/flask_marketplace_test')
SQLALCHEMY_BINDS = {
'master': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace_test',
'read': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace_test'
}
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_TRACK_MODIFICATIONS = True
class ProductionConfig(Config):
DEBUG = False
SECRET_KEY = os.environ.get('ProductionServer_SECRET_KEY') or 'ProductionServer_SECRET_KEY'
# Database SQLAlchemy Configuration
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL',
'postgresql://postgres:postgres'
'@localhost:5432/flask_marketplace')
# Enable Write/Reading on Master/Slave DB servers
SQLALCHEMY_BINDS = {
'master': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace',
'read': 'postgresql://postgres:postgres@localhost:5432/flask_marketplace'
}
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_POOL_SIZE = 10
SQLALCHEMY_MAX_OVERFLOW = 15
config_by_name = {
'development': DevelopmentConfig,
'test': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}
key = Config.SECRET_KEY