api_response.py 366 B

12345678910111213141516
  1. class APIResponse():
  2. msg = 'ok'
  3. error = 0
  4. data = {}
  5. def __init__(self, data, msg=None, error=None, header=None):
  6. if msg:
  7. self.msg = msg
  8. self.data = data
  9. def body(self):
  10. body = self.__dict__
  11. body["data"] = self.data
  12. body["msg"] = self.msg
  13. body["code"] = self.error
  14. return body