Issue
Hello I am certain that I have the image selected in the proper directory but the image isn't showing up. I did run the home.html file which the image is displaying but when I try to do the same when running through my main file the images are showing. Here is the code.
- I am using Flask as well.
'''
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block info%}
<link rel="stylesheet" href = "{{url_for('static', filename='style.css')}}">
<h3 style="color:rgb(0, 0, 0);font-size:40px;" align="center">Home</h3>
<body>
<section>
<h2 align="center">Template 1</h2>
<img
src="img/Fruit1.jpg"
alt="fruit 1"
class="center">
<p align="center"> This is the first template</p>
</section>
</body>
{% endblock %} '''
- When running through main.py
- When running through the HTML file
Solution
Hello I found the problem, it had nothing to do with the HTML, it was just the way Flask was set up. I had to have my folder of images in the static folder in order for it to work. I might remove this post, or keep it up if anyone else might find this useful. I will have to change this to tag to Flask instead of HTML. Everyone have a great day.
I was suppose to change the src for the image to this once my image folder was added to the static folder.
src="{{url_for('static',filename='/img/Fruit1.jpg')}}"
Answered By - S B
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.