aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/markdown_routes.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py
index e43b9860..59a465e7 100644
--- a/wqflask/wqflask/markdown_routes.py
+++ b/wqflask/wqflask/markdown_routes.py
@@ -18,16 +18,25 @@ policies_blueprint = Blueprint("policies_blueprint", __name__)
facilities_blueprint = Blueprint("facilities_blueprint", __name__)
-def render_markdown(file_name):
+def render_markdown(file_name, is_remote_file=True):
"""Try to fetch the file name from Github and if that fails, try to
look for it inside the file system """
github_url = ("https://raw.githubusercontent.com/"
"genenetwork/gn-docs/master/")
+ if not is_remote_file:
+ text = ""
+ with open(file_name, "r", encoding="utf-8") as input_file:
+ text = input_file.read()
+ return markdown.markdown(text,
+ extensions=['tables'])
+
md_content = requests.get(f"{github_url}{file_name}")
+
if md_content.status_code == 200:
+ return markdown.markdown(md_content.content.decode("utf-8"),
+ extensions=['tables'])
- return markdown.markdown(md_content.content.decode("utf-8"), extensions=['tables'])
return (f"\nContent for {file_name} not available. "
"Please check "
"(here to see where content exists)"
@@ -59,7 +68,21 @@ def references():
@environments_blueprint.route("/")
def environments():
- return render_template("environment.html", rendered_markdown=render_markdown("general/environments/environments.md")), 200
+ md_file = get_file_from_python_search_path("wqflask/DEPENDENCIES.md")
+ if md_file is not None:
+ return (
+ render_template("environment.html",
+ rendered_markdown=render_markdown(
+ md_file,
+ is_remote_file=False)),
+ 200
+ )
+ # Fallback: Fetch file from server
+ return (render_template(
+ "environment.html",
+ rendered_markdown=render_markdown(
+ "general/environments/environments.md")),
+ 200)
@links_blueprint.route("/")