aboutsummaryrefslogtreecommitdiff
path: root/uploader/base_routes.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/base_routes.py')
-rw-r--r--uploader/base_routes.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/uploader/base_routes.py b/uploader/base_routes.py
new file mode 100644
index 0000000..742a254
--- /dev/null
+++ b/uploader/base_routes.py
@@ -0,0 +1,53 @@
+"""Basic routes required for all pages"""
+import os
+from urllib.parse import urljoin
+
+from flask import (Blueprint,
+ current_app as app,
+ send_from_directory)
+
+from uploader.ui import make_template_renderer
+from uploader.oauth2.client import user_logged_in
+
+base = Blueprint("base", __name__)
+render_template = make_template_renderer("home")
+
+
+@base.route("/favicon.ico", methods=["GET"])
+def favicon():
+ """Return the favicon."""
+ return send_from_directory(os.path.join(app.root_path, "static"),
+ "images/CITGLogo.png",
+ mimetype="image/png")
+
+
+@base.route("/", methods=["GET"])
+def index():
+ """Load the landing page"""
+ return render_template("index.html" if user_logged_in() else "login.html",
+ gn2server_intro=urljoin(app.config["GN2_SERVER_URL"],
+ "/intro"))
+
+def appenv():
+ """Get app's guix environment path."""
+ return os.environ.get("GN_UPLOADER_ENVIRONMENT")
+
+@base.route("/bootstrap/<path:filename>")
+def bootstrap(filename):
+ """Fetch bootstrap files."""
+ return send_from_directory(
+ appenv(), f"share/genenetwork2/javascript/bootstrap/{filename}")
+
+
+@base.route("/jquery/<path:filename>")
+def jquery(filename):
+ """Fetch jquery files."""
+ return send_from_directory(
+ appenv(), f"share/genenetwork2/javascript/jquery/{filename}")
+
+
+@base.route("/node-modules/<path:filename>")
+def node_modules(filename):
+ """Fetch node-js modules."""
+ return send_from_directory(
+ appenv(), f"lib/node_modules/{filename}")