liveBook · Manning

Dynamic content

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

Dynamic content is information generated or retrieved at request time rather than being identical for every access.

Dynamic content is information generated or retrieved when a web request is handled, rather than identical on every access. A Flask route can return a random value, calculation, database result, or response from another HTTP service. section 6.4.3

Useful pages combine this changing information with stable HTML. Keep HTML in templates instead of embedding large strings in Python, then use Jinja2 placeholders to merge data into a browser-ready document. section 6.4.3

Rendering the current time

A route passes datetime.now() to index.html with render_template(). The template places {{now}} inside an <h1>, producing a page whose displayed time changes when it is served.

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Explains dynamic values, separates HTML from Python, and demonstrates template rendering without covering deeper application architecture.
Examples
Uses random values, calculations, database results, HTTP responses, f-string formatting, and a current-time Flask page.
What it assumes
Assumes familiarity with Python functions and HTML while introducing template placeholders and separating presentation from server code.
What you can do after
Build it from scratch by passing generated Python values into Jinja2 templates rendered by Flask.
How it connects
Connects web applications with Flask, HTML, templates, Jinja2, databases, calculations, and HTTP services.

Also explained in

Compare how 2 books explain dynamic content →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.