__init__.py
1.1 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
import os
from flask import Flask
# Please, set a config file on top project dir
# find example in ressources/app_config.py
try:
from app_config import Config, ProdConfig, DevConfig, TestConfig
except ImportError:
pass
def create_app(config_class=None):
""" App Factory.
can be called with configuration class as argument.
"""
# Configuration Switcher
# try to set configuration depending on environment
# if no configuration class was given
#
if config_class is None:
FLASK_ENV = os.environ.get('FLASK_ENV')
if not FLASK_ENV:
FLASK_ENV = 'testing'
if FLASK_ENV == 'production':
config_class = ProdConfig
elif FLASK_ENV == 'development':
config_class = DevConfig
elif FLASK_ENV == 'testing':
config_class = TestConfig
else:
config_class = Config
# Main flask app
#
app = Flask(__name__)
app.config.from_object(config_class)
# Get and activate blueprints
#
from .main import bp as main_bp
app.register_blueprint(main_bp)
return app