I am currently working on a Flask application where one of the routes generates a list of data that I intend to display in a dropdown menu on the front-end. The challenge lies in the fact that each list may vary in length, with different users having different numbers of items in their accounts. For instance, one user may have three items while another might have twenty.
The route in my code appears as follows:
@app.route("/test", methods=['GET', 'POST'])
def test():
# List generation with 10 items takes place here
return render_template('test.html', title="test", list=list)
My HTML structure is expected to be like this:
{% for x in list %}
<select>
<option value="tester">tester1</option>
<option value="tester2">tester2</option>
<option value="tester3">tester3</option>
<option value="tester4">tester4</option>
</select>
{% endfor %}
The list provided to the template contains ten items, as mentioned in the comment within my initial code snippet (this number can change dynamically). On the other hand, the number of options in my dropdown remains static. What would be the most effective way to dynamically populate this dropdown without involving EXCEL or a database?