I have stored images in a sqlite class Blog, the columns are:
- img: Binary image data
- img_mimetype: Mime Type.
class Blog(db.Model):
id = db.Column(db.Integer, primary_key=True)
img = db.Column(db.Text, nullable=False)
img_mimetype = db.Column(db.Text, nullable=False)
How can I return the image itselft to insert it in an HTML template? I currently have this. but I cannot access the image itself.
@app.route('/')
def index():
blog_posts = get_posts()
return render_template('index.html', blog_posts=blog_posts)
def get_posts():
posts = Blog.query.order_by(Blog.date_created).all()
return posts
The goal is to have something like this:
{% for project in projects %}
<img class="project-card-img" src="{{project.img}}"
{% endfor %}