I trying to pass selected item from the dropdown list, when user click on submit button.
Here is below code in HTML
<form action="/switchinfo" method="post">
<div align="center" id="mainselection">
<select name="sites" method="GET" action="/">
<option selected="selected">Select an the site</option>
{% for site in sites[0:] %}
<option value="{{site}}">{{site}}</option>
{% endfor %}
</select>
</div>
<button class="button execute" name="submit" value="submit">Submit</button>
</form>
Here is the python code
@app.route('/', methods=['GET', 'POST'])
def index():
sites = ['DC1', 'DC2', 'DC3', 'DC4']
return render_template('index.html', sites=sites)
@app.route('/switchinfo', methods=['POST'])
def switchinfo():
gather = request.form["site"]
return render_template("switchinfo.html",gather=gather)
if __name__ == "__main__":
app.run()
getting error werkzeug.exceptions.BadRequestKeyError
.
Thanks for the help