'I want to fetch images from folder one after another using flask and display it on front end in same container with certain interval of time
app.py
In this code I am trying to fetch images from folder one after another on same container the problem is images are not displaying on dashboard one after another after.
from flask import Flask, render_template
import os
app = Flask(__name__)
picfolder=os.path.join('static','photos')
app.config['UPLOAD_FOLDER'] = picfolder
Allowed_Extensions=set(['png','jpg','jpeg','gif'])
@app.route("/")
def index():
pic1=os.path.join(app.config['UPLOAD_FOLDER'],"img1.JPG")
imageList = os.listdir('static/photos/')
imagelist = ['photos/DSC_0175.jpg/' + image for image in imageList]
return render_template("index.html", imagelist=imagelist)
if __name__=="__main__":
app.run()
HTML
<div class="videoSection">
<div class="liveVideoContainer">
<h3>Live</h3>
{% for imagelist in imagelist %}
<img src=" {{url_for('static',filename='imagelist' )}} " width="80" height="142">
{% endfor %}
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
