I have a simple Flask app (Flask version 1.0.3
) with a single app. URL /ask
and handler to process a POST query string of (name, value) pairs, but the request.args
object is not storing all the parameter pairs, only the first pair. Why are the others dropping out?
I've already tried printing out the request.args
object but it only shows the first parameter pair.
Here's the Flask app
import json
from flask import (
Flask,
jsonify,
request,
Response
)
app = Flask(__name__)
@app.route('/')
def home():
return jsonify(message="Hello, World!")
@app.route('/ask', methods=['POST'])
def ask():
return str(request.args)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
Here's the simple query, using the http
CLI tool, with two parameters and the response args - note the response args only contains the first parameter
$ http POST http://127.0.0.1:5000/ask?q1=name&q2=address
[1] 58720
[2019-06-12 15:29:27 $ HTTP/1.0 200 OK
Content-Length: 36
Content-Type: text/html; charset=utf-8
Date: Wed, 12 Jun 2019 14:29:27 GMT
Server: Werkzeug/0.15.4 Python/3.6.2
ImmutableMultiDict([('q1', 'name')])
I get the same result using curl
curl -X POST http://127.0.0.1:5000/nest?q1=name&q2=address
Is there something I'm missing