Flask 为什么我上传的图片没有显示在heroku上
我最近在Heroku上开发了一个Flask Web应用程序。图像将上载到数据库的Flask 为什么我上传的图片没有显示在heroku上,flask,heroku,sqlalchemy,Flask,Heroku,Sqlalchemy,我最近在Heroku上开发了一个Flask Web应用程序。图像将上载到数据库的文本列中。在我使用SQLite的开发机器上,这一切都很好。但在希罗库的postgres上,这些图像无法显示出来 类广告(db.Model): id=db.Column(db.Integer,主键=True) image=db.Column(db.Text) @app.route(“/get_image/”) def get_图像(id): img=db.session.query(Ads).filter_by(id=
文本列中。在我使用SQLite的开发机器上,这一切都很好。但在希罗库的postgres上,这些图像无法显示出来
类广告(db.Model):
id=db.Column(db.Integer,主键=True)
image=db.Column(db.Text)
@app.route(“/get_image/”)
def get_图像(id):
img=db.session.query(Ads).filter_by(id=id).first()
返回响应(img.image)
{%用于imb%中的行]
{{row.brand}}
{{row.price}},{{{row.category}}
{{row.description}}
{%endfor%}
在Postgresql中,将字节写入文本列的行为不会像您预期的那样,正如我在回答上一个问题时指出的那样。Sqlite在这方面比Postgresql更宽容,这就是它在本地工作的原因。谢谢,我今天早上刚刚读了它
{% for row in imb %}
<div class="col-sm-4">
<div class="thumbnail">
<p><strong>{{row.brand}}</strong></p>
<img src="{{url_for('get_image',id = row.id)}}" alt="doctor" width="250" height="100">
<p><strong> {{row.price}} , {{row.category}} </strong>
<p><strong> {{row.description}} </strong>
<a href="/update/{{row.id}}" data-toggle="modal" data-target="#modaledit{{row.id}}" ><i class="fa fa-edit fa-2x" ></i></a>
<a href="/delete/{{row.id}}"><i class="fa fa-trash fa-2x"></i></a>
</div>
</div>
{% endfor %}