单击提交时会显示没有选择值的空表单。即使单击提交后,如何在同一页面上保留图像和选择选项与选项列表。我已经提供了尽可能多的细节。提前致谢!!
这是仪表板.py
@app.route('/',methods=["GET","POST"])
def home():
if request.method=="GET":
#tl contains a list of topic list
return render_template("main.html",topics=tl)
else:
#images_list contains a list of images
return render_template("dashboard.html",img=images_list)
这是 main.html
<html>
<body>
<div class="header">
<img src="static\twitter1.png" alt="logo" />
<h1>Twitter Dashboard</h1>
</div>
<form action = "/" method = 'POST'>
<div class="selectdiv">
<b>Topic</b>
<select name="topic_list">
{% for each in topics %}
<option value="{{each}}" selected="{{each}}">{{each}}</option>
{% endfor %}
</select>
<input type="submit" value="Submit"/>
</div>
</form>
</body>
{% block content %}
{% endblock content %}
</html>
这是dashboard.html
{% extends "main.html"%}
{% block content %}
<body>
{% for row in img1 %}
<img src="static\images\{{row}}" >
{%endfor%}
</body>
{%endblock%}