[英]how to show my image in html through python
在我看來,index.html的代碼是:
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<strong><h1>FlowTow</h1></strong>
<b><h3>POWERED BY BOOTSTRAP</h3></b>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
% for item in result:
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 image">
<p class="username">{{item['user']}}</p>
<p class="dates">{{item['timestamp']}}</p>
<div class="clearfix"></div>
<img src="static/images/{{item['filename']}}" alt="{{item['filename']}}" class="img-responsive imagee">
<p class="likes">{{ item['likes'] }}Likes</p>
<form action="/like" method="post" class="like_form">
<input type="hidden" name="filename" value="{{item['filename']}}">
<input type="submit" class="btn btn-success" value="Like">
</form>
<div class="clearfix"></div>
</div>
% end
</div>
</div>
但是索引不顯示圖像。 該圖像存儲在我的文件“ static / images”中。 當我檢查網站的元素時,圖像的地址顯示為:
<img src="static/images/cycling.jpg" alt="cycling.jpg" class="img-responsive imagee">
我確定圖片的網址正確。 有人可以告訴我為什么不顯示圖像嗎?
該文檔顯示了如何提供靜態文件:
只需在您的應用中為其創建路由並使用static_file()
函數
from bottle import static_file
@route('/static/<filepath:path>')
def server_static(filepath):
return static_file(filepath, root='/path/to/your/static/files')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.