how to get data from post to flask code example
Example 1: posted data to flask
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/post')
def post():
r = request.json
return jsonify(res)
app.run()
Example 2: get post request data flask
@app.route('/form-example', methods=['GET', 'POST'])
def form_example():
if request.method == 'POST':
language = request.form.get('language')
framework = request.form['framework']
return '''<h1>The language value is: {}</h1>
<h1>The framework value is: {}</h1>'''.format(language, framework)
return '''<form method="POST">
Language: <input type="text" name="language"><br>
Framework: <input type="text" name="framework"><br>
<input type="submit" value="Submit"><br>
</form>'''