from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin


class PingMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.method == "GET":
            if request.path == "/ping.json":
                return self.ping(request)
        pass

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        return HttpResponse("OK")

from django.http import HttpResponse


class PingMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.ping(request) or self.get_response(request)

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        if request.method == "GET":
            if request.path == "/ping.json":
                return HttpResponse("OK")

Remove use of django.utils.deprecation.MiddlewareMixin for PingMiddleware and upgrade Middleware to latest spec
Remove use of django.utils.deprecation.MiddlewareMixin for PingMiddleware and  upgrade Middleware to latest spec

  from django.http import HttpResponse
- from django.utils.deprecation import MiddlewareMixin
  
  
- class PingMiddleware(MiddlewareMixin):
-     def process_request(self, request):
-         if request.method == "GET":
-             if request.path == "/ping.json":
-                 return self.ping(request)
-         pass
+ class PingMiddleware:
+     def __init__(self, get_response):
+         self.get_response = get_response
+ 
+     def __call__(self, request):
+         return self.ping(request) or self.get_response(request)
  
      def ping(self, request):
          """
          Returns that the server is alive.
          """
+         if request.method == "GET":
+             if request.path == "/ping.json":
-         return HttpResponse("OK")
+                 return HttpResponse("OK")
  
Remove use of django.utils.deprecation.MiddlewareMixin for PingMiddleware and upgrade Middleware to latest spec
## Code Before:
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin


class PingMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.method == "GET":
            if request.path == "/ping.json":
                return self.ping(request)
        pass

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        return HttpResponse("OK")

## Instruction:
Remove use of django.utils.deprecation.MiddlewareMixin for PingMiddleware and upgrade Middleware to latest spec
## Code After:
from django.http import HttpResponse


class PingMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.ping(request) or self.get_response(request)

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        if request.method == "GET":
            if request.path == "/ping.json":
                return HttpResponse("OK")
