我尝试上传并在我的模板html上显示图像。当我上传图片时,我获得了成功。但是当我想显示图像时,服务器会说:"得到静态404"
有人可以帮忙吗?
#views.py
@app.route("/upload/<username>", methods=['GET', 'POST'])
@login_required
def upload(username):
form = PhotoForm()
user = User.query.filter_by(username=username).first()
if request.method == 'POST' and form.validate_on_submit():
f = form.photo.data
filename = secure_filename(f.filename)
f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return redirect(url_for ('user', username=user.username, filename=filename, f=f))
return render_template("change_profile_picture.html",form=form)
#user.html <img src="{{ url_for('static', filename=filename) }}">****