render_template is a Flask function that renders a named HTML template and returns the resulting response. It keeps webpage markup in separate template files instead of embedding HTML directly in Python route code. section 13.3.3
A typical data-driven page uses render_template to:
- Select an HTML file such as main_page.html or core_metrics.html. section 13.3.3 section 13.3.4
- Pass Python values into template placeholders, such as feature_distributions=fd. section 13.3.4
- Render generated visualizations or prediction data inside the webpage. section 13.3.4 section 13.3.6
Render a page with generated data
from flask import Flask, render_template @app.route('/core-metrics') def core_metrics(): fd = generate_feature_distributions(df) return render_template('core_metrics.html', feature_distributions=fd) The template can reference the value with {{ feature_distributions|safe }} when the generated value should be rendered as HTML.



