Issue
How to display a dictionary on an html page with flask? Sorry for the stupid question, I can't find a good example of both an html page and a python file.
Solution
backend
@app.route('/')
def print_dict():
d = {'hello': 'world'}
return render_template('base.html', d=d)
base.html:
<ul>
{% for key, value in d.items() %}
<li>{{ key }}: {{ value}} </li>
{% endfor %}
</ul>
Answered By - orion_tvv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.