aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2020-11-03 19:16:17 +0300
committerBonfaceKilz2020-11-03 21:04:27 +0300
commitddd071b2bd50d243c01c335e06955316df08fc45 (patch)
treeffb86a85b518bbe53e7f6d5d5e7168d3db5a4089
parent390dcc3c46495a8e316df36ceb57dae2089456da (diff)
downloadgenenetwork2-ddd071b2bd50d243c01c335e06955316df08fc45.tar.gz
Rename glossary.py to markdown_routes.py
Evary page with markdown content will have routes added in markdown_routes.py * markdown_routes.py: New file. * wqflask/wqflask/glossary.py: Delete it. * wqflask/wqflask/__init__.py: Update import.
-rw-r--r--wqflask/wqflask/__init__.py2
-rw-r--r--wqflask/wqflask/glossary.py9
-rw-r--r--wqflask/wqflask/markdown_routes.py29
3 files changed, 30 insertions, 10 deletions
diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py
index a3870ce6..874cde17 100644
--- a/wqflask/wqflask/__init__.py
+++ b/wqflask/wqflask/__init__.py
@@ -6,7 +6,7 @@ import jinja2
from flask import g
from flask import Flask
from utility import formatting
-from wqflask.glossary import glossary_blueprint
+from wqflask.markdown_routes import glossary_blueprint
app = Flask(__name__)
diff --git a/wqflask/wqflask/glossary.py b/wqflask/wqflask/glossary.py
deleted file mode 100644
index a44e7c45..00000000
--- a/wqflask/wqflask/glossary.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from flask import Blueprint
-from flask import render_template
-
-glossary_blueprint = Blueprint('glossary_blueprint', __name__)
-
-
-@glossary_blueprint.route('/')
-def glossary():
- return render_template("glossary.html"), 200
diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py
new file mode 100644
index 00000000..e7e3c33e
--- /dev/null
+++ b/wqflask/wqflask/markdown_routes.py
@@ -0,0 +1,29 @@
+"""Markdown routes
+
+Render pages from github, or if they are unavailable, look for it else where
+"""
+import requests
+import mistune
+
+from flask import Blueprint
+from flask import render_template
+
+glossary_blueprint = Blueprint('glossary_blueprint', __name__)
+
+
+@glossary_blueprint.route('/')
+def glossary():
+ markdown_url = ("https://raw.githubusercontent.com"
+ "/genenetwork/genenetwork2/"
+ "wqflask/wqflask/static"
+ "/glossary.md")
+ md_content = requests.get(markdown_url)
+ if md_content.status_code == 200:
+ return render_template(
+ "glossary_html",
+ rendered_markdown=mistune.html(
+ md_content.content.decode("utf-8"))), 200
+
+ return render_template(
+ "glossary.html",
+ rendered_markdown=mistune.html("# Github Down!")), 200