【发布时间】:2018-06-01 08:10:32
【问题描述】:
我正在尝试以静态(静态/绘图)显示特定目录中的所有图像。这是我的蟒蛇:
hists = os.listdir('static/plots')
hists = ['plots/' + file for file in hists]
return render_template('report.html', hists = hists)
还有我的html:
<!DOCTYPE=html>
<html>
<head>
<title>
Store Report
</title>
</head>
<body>
{{first_event}} to {{second_event}}
{% for hist in hists %}
<img src="{{url_for('static', filename='{{hist}}')}}" alt="{{hist}}">
{% endfor %}
</body>
</html>`
并且当模板成功渲染时,不会获取模板。在新选项卡中打开图像会产生:
@987654321@
我想问题出在这条线上,但我不知道什么是正确的:
<img src="{{url_for('static', filename='{{hist}}')}}" alt="{{hist}}">
【问题讨论】: