Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Unable to display image in html flask

New member
Joined
Feb 14, 2023
Messages
10
I'm trying to render an image in html in flask, the path is pointing to the correct file but its not rendering some how.

#VIEWS

Code:
@inventory_bp.route("/show")
def show_image():
    id = 3
    image = Images.query.get(id)
    upload_folder = app.config['UPLOAD_FOLDER']
    image_path = os.path.join(upload_folder, image.filename)
    return render_template("image-upload.html",image_url=image_path)

#HTML

Code:
    <div>
      <img src="{{ image_url }}" alt="" />
    </div>

Code:
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'flaskbp/uploads')
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

enter image description here
 
Top