i have a result folder in my static directory with nine images called 'result_1.jpg' to 'result_9.jpg' and i want to display them in the correct order in a grid on my html page.
Everything works fine, except the output order is completely random but always the same.
Here's my python snippet:
@app.route('/fResults/')
def show_fResults():
imgs = os.listdir('static/results/')
imgs = ['results/' + file for file in imgs]
return render_template('fResults.html', imgs = imgs)
Here's my html snippet:
<div class="resultGrid">
{% for img in imgs %}
<div class="resultImages">
<img id="results" src="{{ url_for('static', filename = img) }}" alt="{{loop.index}}">
</div>
{% endfor %}
</div>
And here is the html output:
Is there a way to force it to use a given order?
Thank you in advance!
EDIT: Thanks to Epsi95 I was able to fix my problem.
@Epsi95 thank you very much!