From 0189538cefa19668b8167c39717869340aed594a Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 15 Feb 2021 09:47:29 +0300 Subject: Bootsrap the flask application --- gn3/app.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gn3/app.py (limited to 'gn3') diff --git a/gn3/app.py b/gn3/app.py new file mode 100644 index 0000000..9bdebc1 --- /dev/null +++ b/gn3/app.py @@ -0,0 +1,25 @@ +"""Entry point from spinning up flask""" +import os + +from typing import Dict +from typing import Union +from flask import Flask + + +def create_app(config: Union[Dict, str, None] = None) -> Flask: + """Create a new flask object""" + app = Flask(__name__) + # Load default configuration + app.config.from_object("gn3.settings") + + # Load environment configuration + if "GN3_CONF" in os.environ: + app.config.from_envvar('GN3_CONF') + + # Load app specified configuration + if config is not None: + if isinstance(config, dict): + app.config.update(config) + elif config.endswith(".py"): + app.config.from_pyfile(config) + return app -- cgit v1.2.3