I ran into a problem in Iterating for loop
over several lists in a jinja2 flask template.
My code looks something like
Type = 'RS'
IDs = ['1001','1002']
msgs = ['Success','Success']
rcs = ['0','1']
return render_template('form_result.html',type=type,IDs=IDs,msgs=msgs,rcs=rcs)
I'm not sure I’ll come up with the right template,
<html>
<head>
<title>Response</title>
</head>
<body>
<h1>Type - {{Type}}!</h1>
{% for reqID,msg,rc in reqIDs,msgs,rcs %}
<h1>ID - {{ID}}</h1>
{% if rc %}
<h1>Status - {{msg}}!</h1>
{% else %}
<h1> Failed </h1>
{% endif %}
{% endfor %}
</body>
</html>
The output I'm trying to get is something like below on the html page
Type - RS
ID - 1001
Status - Failed
ID - 1002
Status - Success
source
share