Templates

Flask comes with Jinja2 support out of the box. Even better it makes it really easy to use templates from within blueprints too.

Code

It’s a little clearer if we look at the full source code too: https://bitbucket.org/micktwomey/building-web-applications-with-flask/src/tip/pythonie/blueprints/templates

Examples of templates

pythonie.blueprints.templates.index(message='from a template')[source]

Renders a page using a template

Parameters:message – Optional message to display

To see in action:

URLs

GET /templates/(message)
GET /templates/

Renders a page using a template

Parameters:
  • message – Optional message to display

To see in action:

GET /

To see this in action go to http://building-webapps-with-flask.herokuapp.com/