Reputation: 863
So I'm trying to send data from an html form to my python flask framework. Here's the example of the html code I'm using
<form method=post action=/test>
<input name=Name value=Austin type=hidden><input type=submit value="Add Notification">
and here's the python flask I'm working with
@app.route('/test', methods=('GET', 'POST')
def test_page():
v = request.values.get('Name')
return v
I've tried many different request methods and can't seem to get it to work and I get a 405 error. I'm not very familiar with the flask web development or using post requests. If anyone could point me in the correct direction then that'd be great!
Upvotes: 0
Views: 1997
Reputation: 1605
You're POST
ing to your endpoint, but app.route
by default only enables GET
. Change app.route('/test')
to app.route('/test', methods=('GET', 'POST'))
, and you'll be able to access your endpoint.
That 405
response you're getting is Method Not Allowed.
(Unrelated issue, request.values.get['Name']
should be request.values.get('Name')
.)
Upvotes: 3