Html ran in a python flask image error

Question:
I have created a website using Flask, where I’m serving an HTML file via a Flask server. However, when I try to add an <img> element to display an image on the webpage, the image doesn’t load. It’s worth noting that when I tried the same HTML code in a standalone HTML project, it worked perfectly. The issue seems to be specific to running the HTML file via a Flask server in Python. How can I resolve this problem and make the image load correctly?

Repl link:
https://replit.com/@GerroPogi/Among-us-website-lol

<img src="cool.jpg">
1 Like

Hi, flask will not serve every file as that is a security vulnerability. Instead you should put your image into the static/ directory, and set the img src to /static/cool.jpg.

5 Likes

Thank you so much, It took me an hour to try to fix this problem with no fix. I hope you well in the future!

1 Like

Hi @GerroPogi ! If @CodingCactus answered your question, you can mark that as a Solution.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.