From a28f27206ba145d25c148b0f20f2ad20ace225fe Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 6 Mar 2020 17:51:20 -0600 Subject: [PATCH] basic create_app() and configuration scaffolding --- incorporealcms/__init__.py | 21 +++++++++++++++++++++ incorporealcms/config.py | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 incorporealcms/__init__.py create mode 100644 incorporealcms/config.py diff --git a/incorporealcms/__init__.py b/incorporealcms/__init__.py new file mode 100644 index 0000000..c4820cf --- /dev/null +++ b/incorporealcms/__init__.py @@ -0,0 +1,21 @@ +"""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) + + return app diff --git a/incorporealcms/config.py b/incorporealcms/config.py new file mode 100644 index 0000000..73776eb --- /dev/null +++ b/incorporealcms/config.py @@ -0,0 +1,11 @@ +"""Default configuration.""" + + +class Config(object): + """Represent the default configuration. + + Reminder: this should be overwritten in the instance config.py, not here! + """ + + DEBUG = False + TESTING = False