-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
51 lines (39 loc) · 1.38 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
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 DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")
)
# SQLALCHEMY_DATABASE_URI = "postgresql://dbuser:123456@localhost:5432/restxplate"
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = True
class TestingConfig(Config):
DEBUG = True
TESTING = True
# In-memory SQLite for testing
SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
class ProductionConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "sqlite:///" + os.path.join(basedir, "data.sqlite")
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# collect all configs into dict
config_by_name = dict(
development=DevelopmentConfig,
testing=TestingConfig,
production=ProductionConfig,
default=DevelopmentConfig,
)