From 416cb0cd272001651a3d9eb43500067ef524819d Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 26 Nov 2020 15:09:37 +0300 Subject: add endpoint for polices,environments and policies --- wqflask/wqflask/markdown_routes.py | 51 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py index 60d4374c..5170fcf0 100644 --- a/wqflask/wqflask/markdown_routes.py +++ b/wqflask/wqflask/markdown_routes.py @@ -9,23 +9,31 @@ from flask import Blueprint from flask import render_template glossary_blueprint = Blueprint('glossary_blueprint', __name__) -references_blueprint=Blueprint("references_blueprint",__name__) -environments_blueprint=Blueprint("environments_blueprint",__name__) -links_blueprint=Blueprint("links_blueprint",__name__) -policies_blueprint=Blueprint("policies_blueprint",__name__) +references_blueprint = Blueprint("references_blueprint", __name__) +environments_blueprint = Blueprint("environments_blueprint", __name__) +links_blueprint = Blueprint("links_blueprint", __name__) +policies_blueprint = Blueprint("policies_blueprint", __name__) -def render_markdown(file_name): +#for debug +github_url = ("https://raw.githubusercontent.com/" + "genenetwork/gn-docs/master/general/glossary/glossary.md") + + + +def render_markdown(file_name,github_url="https://raw.githubusercontent.com/Alexanderlacuna/gn-docs/feature/add-markdown-pages/"): + + md_content=requests.get(f"{github_url}{file_name}") """Try to fetch the file name from Github and if that fails, try to look for it inside the file system - +po """ - github_url = ("https://raw.githubusercontent.com/" - "genenetwork/gn-docs/master/") - md_content = requests.get(f"{github_url}{file_name}") + # github_url = ("https://raw.githubusercontent.com/" + # "genenetwork/gn-docs/master/") + # md_content = requests.get(f"{github_url}{file_name}") if md_content.status_code == 200: + # print(md_content.content.decode("utf-8")) return markdown.Markdown().convert(md_content.content.decode("utf-8")) - # TODO: Add fallback on our git server by checking the mirror. # Content not available @@ -36,8 +44,6 @@ look for it inside the file system "Please reach out to the gn2 team to have a look at this") - - @glossary_blueprint.route('/') def glossary(): return render_template( @@ -48,23 +54,24 @@ def glossary(): @references_blueprint.route('/') def references(): return render_template( - "reference.html", - rendered_markdown=render_markdown("general/glossary/glossary.md")), 200 - + "references.html", + rendered_markdown=render_markdown("general/references/references.md")), 200 @environments_blueprint.route("/") -def references(): - return render_template("environments.html",rendered_markdown=render_markdown("general/environments/environments.md")) +def environments(): + return render_template("environments.html", rendered_markdown=render_markdown("general/links/links.md")) @links_blueprint.route("/") def links(): - return rendered_template("links.html",rendered_markdown=render_markdown("general/links/links.md")) + return render_template( + "links.html", + rendered_markdown=render_markdown("general/links/links.md")), 200 -policies_blueprint.route("/") +@policies_blueprint.route("/") def policies(): - return rendered_template("policies.html",rendered_markdown=rendered_markdown("general/policies/policies.md")) - - + return render_template( + "links.html", + rendered_markdown=render_markdown("general/policies/policies.md")), 200 -- cgit v1.2.3