Flask API TypeError: Object of type 'Response' is not JSON serializable

后端 未结 4 1652
栀梦
栀梦 2021-02-12 11:41

i have a problem with Python Flask Restful API and data goes to Elasticsearch, when i post a new data with Postman, problem is:

TypeError: Object of type \'Response\' is

4条回答
  •  感动是毒
    2021-02-12 12:36

    This can be simply done by:

    from flask import jsonify
    def myMethod():
        ....
        response = jsonify(data)
        response.status_code = 200 # or 400 or whatever
        return response
    

提交回复
热议问题