I'm trying to create a dropdown menu in HTML using info from a python script. I've gotten it to work thus far, however, the html dropdown displays all 4 values in the lists as 4 options.
Current: Option 1: Red, Blue, Black Orange; Option 2: Red, Blue, Black, Orange etc. (Screenshot in link) Current
Desired: Option 1: Red Option 2: Blue etc.
How do I make it so that the python list is separated?
dropdown.py
from flask import Flask, render_template, request
app = Flask(__name__)
app.debug = True
@app.route('/', methods=['GET'])
def dropdown():
colours = ['Red', 'Blue', 'Black', 'Orange']
return render_template('test.html', colours=colours)
if __name__ == "__main__":
app.run()
test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dropdown</title>
</head>
<body>
<select name= colours method="GET" action="/">
{% for colour in colours %}
<option value= "{{colour}}" SELECTED>{{colours}}</option>"
{% endfor %}
</select>
</body>
</html>