July 2019
Beginner to intermediate
302 pages
9h 38m
English
An amalgamation of both GET and POST into a single view function can be written as shown below:
@app.route('/a-request', methods=['GET', 'POST'])
def some_request():
if request.method == 'GET':
bar = request.args.get('foo', 'bar')
else:
bar = request.form.get('foo', 'bar')
return 'A simple Flask request where foo is %s' % bar