1

I try to upload and display an image on my template html. When I upload an image, I have success. But when I want to display the image, the server is saying: "get static 404"

Can anyone help?

#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) }}">****
Zik
  • 202
  • 3
  • 11
  • Same as https://stackoverflow.com/questions/46785507/python-flask-display-image-on-a-html-page – Zik May 30 '19 at 02:06

0 Answers0