- Flask Framework Cookbook(Second Edition)
- Shalabh Aggarwal
- 52字
- 2021-06-24 13:58:09
A simple GET/POST request
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