· 7 years ago · Mar 26, 2018, 09:34 PM
1import os
2
3# uncomment the line below for postgres database url from environment variable
4# postgres_local_base = os.environ['DATABASE_URL']
5
6basedir = os.path.abspath(os.path.dirname(__file__))
7
8class Config:
9 SECRET_KEY = os.getenv('SECRET_KEY', 'my_precious_secret_key')
10 DEBUG = False
11
12
13class DevelopmentConfig(Config):
14 # uncomment the line below to use postgres
15 # SQLALCHEMY_DATABASE_URI = postgres_local_base
16 DEBUG = True
17 SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'flask_boilerplate_main.db')
18 SQLALCHEMY_TRACK_MODIFICATIONS = False
19
20
21class TestingConfig(Config):
22 DEBUG = True
23 TESTING = True
24 SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'flask_boilerplate_test.db')
25 PRESERVE_CONTEXT_ON_EXCEPTION = False
26 SQLALCHEMY_TRACK_MODIFICATIONS = False
27
28
29class ProductionConfig(Config):
30 DEBUG = False
31 # uncomment the line below to use postgres
32 # SQLALCHEMY_DATABASE_URI = postgres_local_base
33
34
35config_by_name = dict(
36 dev=DevelopmentConfig,
37 test=TestingConfig,
38 prod=ProductionConfig
39)
40
41key = Config.SECRET_KEY