Home > Software engineering >  Trying to use image in Flask website only shows broken img icon
Trying to use image in Flask website only shows broken img icon

Time:05-09

Hi so I'm trying to upload an png image that I saved in my static folder as a background in my little flask website. But I'm unable to do so. Each time I get a image icon (like it can't load it or something).

Here is the html code where I try to insert the png image.

<img src="{{ url_for('static', filename='bgcaf.png') }}" />

Here is the structure of my website folder (I'm trying to display the bgcaf.png in Cafinit.html). [1]: https://i.stack.imgur.com/mEQL5.png

If I left out important info please let me know

CodePudding user response:

url_for is a flask function it works in your py files but not on your templates,this would work just fine

<img src="static/bgcaf.png"/>
  • Related