在html模板中显示上传到烧瓶数据库(BLOB文件)的图像

时间:2019-12-25 05:13:15

标签: python html flask sqlalchemy

我已经将图像从html表单上载到了我的烧瓶sqlAlchemy数据库中,现在我希望存储在数据库中的那个Blob类型文件可以显示在其他html文件中。 我可以使用什么代码?

@app.route('/jj') 
def jj(): 
  return render_template("add_image.html") 

@app.route('/add_image', methods=["GET","POST"]) 
def add_image(): 
  if g.user: 
    zz=user.query.filter_by(username=g.user).first() 
    value1=zz.id 
    value2=zz.username 
    file=request.files['inputfile'] 
    newfile=image(file_name=file.filename,ibt=value2,user_id=value1,data=file.read()) 
    db.session.add(newfile) 
    db.session.commit() 
    #image=request.files["image"] 
    return redirect(url_for('account')),flash("Profile uploaded successfully.")

0 个答案:

没有答案