My problem is that with the given code:
from flask import Flask, request
app = Flask(__name__)
@app.route(\"/\")
def hello():
return str(request.values
Another option is to use a flat json structure with request.args. Because sometimes you simply do not know the parameter beforehand and you cannot use .getlist()
.
arguments = request.args.to_dict(flat=False)
# Get a specific parameter
params = arguments.get('param')
print(params)
# Get all the parameters that have more than one value
for field, values in arguments.items():
if len(values) > 1:
print(values)