在用flask框架将请求结果反馈到前端时,图片的路径没有变,但是新图片会覆盖原图片,后台图片已经更新了,但是显示到前端还是一样。
查资料说是因为地址不变,缓存还在,所以显示的一直是原来的图片。解决办法是:
加一个时间戳,每次都刷新一下。
html文件设置:
<img src="{{url_for('static',filename='outImages/out.jpg',_t=val1)}}" width="600" height="500"/> <!--图片展示-->
python文件设置:
return render_template('show_image.html',dic_res=dic_res,val1=time.time())
注意载入time模块