aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/app.py25
1 files changed, 25 insertions, 0 deletions
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