Flask Snippets

Snippets are unofficial and unmaintained.

This is an archived view of user-submitted snippets. Despite being hosted on the Flask site, they are not official. No Flask maintainer has curated or checked the snippets for security, correctness, or design.

Simple static page rendering

Posted by Leandro Poblet on 2014-10-23 @ 12:20 and filed in Application Structure

If you needed a static pages and fast, like me, here's a simple approach to your problem:

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/<string:page_name>/')
def static_page(page_name):
    return render_template('%s.html' % page_name)

if __name__ == '__main__':
    app.run()

This snippet by Leandro Poblet can be used freely for anything you like. Consider it public domain.