2020-03-06 17:51:20 -06:00
|
|
|
"""create_app application factory function and similar things."""
|
|
|
|
import os
|
|
|
|
|
|
|
|
from flask import Flask
|
|
|
|
|
|
|
|
|
|
|
|
def create_app(test_config=None):
|
|
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
|
|
|
|
# if it doesn't already exist, create the instance folder
|
|
|
|
os.makedirs(app.instance_path, exist_ok=True)
|
|
|
|
|
|
|
|
if test_config is None:
|
|
|
|
# load defaults from config provided with the application
|
|
|
|
app.config.from_object('incorporealcms.config.Config')
|
|
|
|
# load specific instance configurations
|
|
|
|
app.config.from_pyfile('config.py', silent=True)
|
|
|
|
else:
|
|
|
|
app.config.from_mapping(test_config)
|
|
|
|
|
2020-03-06 18:08:24 -06:00
|
|
|
from . import journal
|
|
|
|
app.register_blueprint(journal.bp)
|
|
|
|
|
2020-03-06 17:51:20 -06:00
|
|
|
return app
|