def render_GET(self, request): content = StringIO() with open("page/index") as f: md.convertFile(f, content, "utf-8") context = { "site_description": SITE_DESCRIPTION, "content": content.getvalue().decode("utf-8"), "is_index": True, } return render_template("page.html", request, context)
def render_GET(self, request): if len(request.path.split("/")) != 3: raise BadRequest() name = request.path.split("/")[2] if not name: raise BadRequest() file_path = "page/%s" % name if not os.path.isfile(file_path): raise PageNotFound() with open(file_path) as f: content = StringIO() md.convertFile(f, content, "utf-8") context = { "content": content.getvalue().decode("utf-8"), } return render_template("page.html", request, context)