2
0

format_response.py 297 B

1234567891011121314
  1. import json
  2. from django.http import HttpResponse
  3. def api_response(code, msg='', data=''):
  4. """
  5. 格式化返回
  6. :param code:
  7. :param msg:
  8. :param data:
  9. :return:
  10. """
  11. return HttpResponse(json.dumps(dict(code=code, data=data, msg=msg)), content_type="application/json")