forked from X1Zeth2X/flask-restx-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
53 lines (40 loc) · 1.3 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
import os
from datetime import timedelta
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
# Change the secret key in production run.
SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(24))
DEBUG = False
# JWT Extended config
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY", os.urandom(24))
## Set the token to expire every week
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=7)
class LocalConfig(Config):
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data-local.sqlite")
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Add logger
class DevConfig(Config):
DEBUG = True
TESTING = True
# In-memory SQLite for testing
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")
)
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
class ProdConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data.sqlite")
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
config_by_name = dict(
local=LocalConfig,
dev=DevConfig,
prod=ProdConfig,
default=LocalConfig,
)