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():
You can pass your data using render_template()
like this:
cur = con.cursor()
cur.execute("SELECT * FROM dataset")
data = cur.fetchall()
render_template('template.html', data=data)
Then in your template, iterate over the rows, for example you could render table rows for each row:
{% for item in data %}
{{item[0]}}
{{item[1]}}
...
{% endfor %}