InitController.py 891 B

1234567891011121314151617181920212223242526272829
  1. # @Author : Rocky
  2. # @File : InitController.py
  3. # @Time : 2023/4/11 17:26
  4. from django.http import HttpResponse
  5. from django.views import View
  6. from Object.ResponseObject import ResponseObject
  7. class InitView(View):
  8. def get(self, request, *args, **kwargs):
  9. request.encoding = 'utf-8'
  10. operation = kwargs.get('operation')
  11. return self.validation(request.GET, operation)
  12. def post(self, request, *args, **kwargs):
  13. request.encoding = 'utf-8'
  14. operation = kwargs.get('operation')
  15. return self.validation(request.POST, operation)
  16. def validation(self, request_dict, operation):
  17. if operation == 'health-check': # 负载均衡器健康检测接口
  18. return self.health_check(request_dict)
  19. @staticmethod
  20. def health_check(request_dict):
  21. response = ResponseObject()
  22. return response.json(0)