【发布时间】:2019-08-17 13:27:55
【问题描述】:
我正在构建一个非常简单的 webApp(使用 python flask),它将向用户显示一些图像。如何在子标题下正确显示图片?
从烧瓶应用返回的字典
images:{'fish': ['/images/fish/Jellyfish.jpg'],
'mammal': ['/images/mammal/Koala.jpg']}
}
show.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image Gallery</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<body>
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Images</h1>
</div>
<hr>
{% if images %}
{% for key,value in image.items() %}
<h4>{{key}}<h4>
<hr>
{% for image_name in value %}
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<img class="img-responsive" src=" {{url_for('send_image', filename=image_name)}}">
<hr> </div>
{% endfor %}{% endfor %}{% endif %}
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
【问题讨论】:
标签: python html css flask jinja2