InitController.py 906 B

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