I wrote this easy program:
@app.route('/puttest/', methods=['GET', 'PUT'])
def upload_file():
if request.method == 'PUT':
return 'Hello, {}!'.format(request.form['name'])
else:
return '''
<title>Does it work ?</title>
<h1>PUT test</h1>
<form action=http://localhost:8887/puttest/ method=put>
<input type=text name=name>
<input type=submit value=try>
</form>
'''
if __name__ == '__main__':
app.run('0.0.0.0', 8887)
It works perfectly for GET method, but it doesn't work with PUT. Trying to send put message, I can see this error at a browser:
Method Not Allowed
The method is not allowed for the requested URL.
What has happened to put method ?
It will work fine if I change put method on post everywhere in program.
PUT won't work with HTML method attribute. Allowed values are: method = get|post
You have to use POST in Webforms:
@app.route('/puttest/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
return 'Hello, {}!'.format(request.form['name'])
else:
return '''
<title>Does it work ?</title>
<h1>PUT test</h1>
<form action=http://localhost:8887/puttest/ method=post>
<input type=text name=name>
<input type=submit value=try>
</form>
'''
Further informations at: Using PUT method in HTML form and HTML Standard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With