Reputation: 49
I'm posting data to the following Flask view using an HTML form. For some reason, the server is never created. I've confirmed that the create_server
method works from the interpreter. Another form I'm using to log in works. Why isn't this working?
@app.route('/add-server/', methods=['GET', 'POST'])
def add_server_view():
if request.method == 'post':
server_name = request.form['server_name']
create_server(server_name)
return redirect(url_for('index')
return render_template('add_server.html')
<form method=post>
<input name=server_name>
</form>
Upvotes: 2
Views: 902
Reputation: 127180
request.method
will be in all caps and the comparison is case sensitive.
if request.method == 'POST':
This code in Werkzueg forces the method name to uppercase for consistency.
Upvotes: 1