aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/default_config.py9
-rw-r--r--manifest.scm1
-rw-r--r--qc_app/__init__.py21
-rw-r--r--qc_app/entry.py9
-rw-r--r--qc_app/parse_error.py9
-rw-r--r--qc_app/parse_success.py9
-rw-r--r--wsgi.py20
7 files changed, 78 insertions, 0 deletions
diff --git a/etc/default_config.py b/etc/default_config.py
new file mode 100644
index 0000000..80f9d59
--- /dev/null
+++ b/etc/default_config.py
@@ -0,0 +1,9 @@
+"""
+The default configuration file. The values here should be overridden in the
+actual configuration file used for the production and staging systems.
+"""
+
+import os
+
+LOG_LEVEL = os.getenv("LOG_LEVEL", "WARNING")
+SECRET_KEY = b"<Please! Please! Please! Change This!>"
diff --git a/manifest.scm b/manifest.scm
index c41be35..d5ce588 100644
--- a/manifest.scm
+++ b/manifest.scm
@@ -1,6 +1,7 @@
(specifications->manifest
(list "python"
"python-mypy"
+ "python-flask"
"python-pylint"
"python-pytest"
"python-hypothesis"))
diff --git a/qc_app/__init__.py b/qc_app/__init__.py
new file mode 100644
index 0000000..2dd5758
--- /dev/null
+++ b/qc_app/__init__.py
@@ -0,0 +1,21 @@
+"""The Quality-Control Web Application entry point"""
+
+import os
+from flask import Flask
+
+from .entry import entrybp
+from .parse_error import parseerrbp
+from .parse_success import parsesuccessbp
+
+def create_app(instance_path):
+ """The application factory"""
+ app = Flask(
+ __name__, instance_path=instance_path, instance_relative_config=True)
+ app.config.from_pyfile(os.path.join(os.getcwd(), "etc/default_config.py"))
+ app.config.from_pyfile("config.py") # Override defaults with instance path
+
+ # setup blueprints
+ app.register_blueprint(entrybp, url_prefix="/")
+ app.register_blueprint(parseerrbp, url_prefix="/error")
+ app.register_blueprint(parsesuccessbp, url_prefix="/success")
+ return app
diff --git a/qc_app/entry.py b/qc_app/entry.py
new file mode 100644
index 0000000..4963246
--- /dev/null
+++ b/qc_app/entry.py
@@ -0,0 +1,9 @@
+"""Entry-point module"""
+from flask import Blueprint
+
+entrybp = Blueprint("entry", __name__)
+
+@entrybp.route("/", methods=["GET", "POST"])
+def upload_file():
+ """Enables uploading the files"""
+ return "STUB: We upload the files here"
diff --git a/qc_app/parse_error.py b/qc_app/parse_error.py
new file mode 100644
index 0000000..1414b78
--- /dev/null
+++ b/qc_app/parse_error.py
@@ -0,0 +1,9 @@
+"""Parse Error handling blue print"""
+from flask import Blueprint
+
+parseerrbp = Blueprint("parse_error", __name__)
+
+@parseerrbp.route("/", methods=["GET"])
+def parse_success():
+ """Indicates success if parsing the file is fails"""
+ return "STUB: Parse error!!!"
diff --git a/qc_app/parse_success.py b/qc_app/parse_success.py
new file mode 100644
index 0000000..53b9c42
--- /dev/null
+++ b/qc_app/parse_success.py
@@ -0,0 +1,9 @@
+"""Successful file parsing module"""
+from flask import Blueprint
+
+parsesuccessbp = Blueprint("parse_success", __name__)
+
+@parsesuccessbp.route("/", methods=["GET"])
+def parse_success():
+ """Indicates success if parsing the file is successful"""
+ return "STUB: Parse success!!!"
diff --git a/wsgi.py b/wsgi.py
new file mode 100644
index 0000000..be8207d
--- /dev/null
+++ b/wsgi.py
@@ -0,0 +1,20 @@
+"""Run the application"""
+
+import os
+
+from qc_app import create_app
+
+def instance_path():
+ """Retrieve the `instance_path`. Raise an exception if not defined."""
+ path = os.getenv("QCAPP_INSTANCE_PATH", None)
+ if path is None:
+ raise Exception((
+ "Configuration Error: Set the `QCAPP_INSTANCE_PATH` environment "
+ "variable."))
+
+ return path
+
+app = create_app(instance_path())
+
+if __name__ == "__main__":
+ app.run()