I have a flask app with the following view:
@menus.route('/', methods=["PUT", "POST"])
def new():
return jsonify(request.json)
However, this only works if the request's content type is set to application/json, otherwise the dict request.json is None.
I know that request.data has the request body as a string, but I don't want to be parsing it to a dict everytime a client forgets to set the request's content-type.
Is there a way to assume that every incoming request's content-type is application/json? All I want is to always have access to a valid request.json dict, even if the client forgets to set the application content-type to json.