I'm using Flask for a web app. And I find that the request.args
returns different data when I convert the URL parameters to a dict.
Code is below.
How to make Flask under Python3 return the same data as it returns under Python2?
from flask import Flask,request
import numpy as np
import json
app = Flask(__name__)
@app.route('/')
def hello():
request.parameter_storage_class = dict
return json.dumps(dict(request.args))
app.run()
- Python2:
{"abc": ["hello"]}
- Python3:
{"abc": "hello"}