I have code like this to retrieve data from database and I want to display it in html.
This is app.py
@app.route(\'/news\')
def news():
render_template allows you to pass variables to html, and jinja2 help you to manipulate it. You only need to format your query result and send it within render_template
@app.route('/test')
def test_route():
user_details = {
'name': 'John',
'email': 'john@doe.com'
}
return render_template('test.html', user=user_details)
test
{{user.name}}
{{user.email}}
to make the most of jinja2, take a look at his Documentation