0

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

Alex ._.
  • 3
  • 4

1 Answers1

0

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"/>
  • 1
    I'm afraid part of your answer is incorrect. `url_for` __can__ work in templates. See [here](https://stackoverflow.com/a/7488983/15368978) for an example. It might be a good idea to edit your answer so that others are not accidentally misled. – Patrick Yoder May 08 '22 at 21:07