Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Render JInja template as static site using Flask
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Jinja2 static site renderer using Flask
@author Tarun Bhardwaj
@license FreeBSD Licence
"""
from flask import Flask, abort, render_template
from jinja2 import TemplateNotFound
app = Flask(__name__)
@app.route("/")
@app.route("/<path>")
def main(path=None):
if not path:
path = 'index.html'
try:
return render_template(path)
except TemplateNotFound:
abort(404)
if __name__ == "__main__":
app.debug = True
app.run()
@tarunbhardwaj

This comment has been minimized.

Copy link
Owner Author

tarunbhardwaj commented Jul 17, 2014

TODO: avoid loading templates abstract templates.

i.e. template name starts with '_'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.