aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-02-15 09:47:29 +0300
committerBonfaceKilz2021-02-15 09:47:29 +0300
commit0189538cefa19668b8167c39717869340aed594a (patch)
treedd14127aecd16a20bd2930a6ab542194239e7571
parent9dd23ef8c8ed003be130c212374ffa71f230c463 (diff)
downloadgenenetwork3-0189538cefa19668b8167c39717869340aed594a.tar.gz
Bootsrap the flask application
-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