herokuapp/middleware.py
def process_request(self, request):
        """If the request domain is not the canonical domain, redirect."""
        hostname = request.get_host().split(":", 1)[0]
        # Don't perform redirection for testing or local development.
        if hostname in ("testserver", "localhost", "127.0.0.1"):
            return
        # Check against the site domain.
        canonical_hostname = SITE_DOMAIN.split(":", 1)[0]
        if hostname != canonical_hostname:
            if request.is_secure():
                canonical_url = "https://"
            else:
                canonical_url = "http://"
            canonical_url += SITE_DOMAIN + request.get_full_path()
            return redirect(canonical_url, permanent=True)
If the request domain is not the canonical domain, redirect.
If the request domain is not the canonical domain, redirect.
If the request domain is not the canonical domain redirect .
def process_request(self, request):
        hostname = request.get_host().split(":", 1)[0]
        if hostname in ("testserver", "localhost", "127.0.0.1"):
            return
        canonical_hostname = SITE_DOMAIN.split(":", 1)[0]
        if hostname != canonical_hostname:
            if request.is_secure():
                canonical_url = "https://"
            else:
                canonical_url = "http://"
            canonical_url += SITE_DOMAIN + request.get_full_path()
            return redirect(canonical_url, permanent=True)
def process_request ( self , request ) : hostname = request . get_host ( ) . split ( ":" , 1 ) [ 0 ] if hostname in ( "testserver" , "localhost" , "127.0.0.1" ) : return canonical_hostname = SITE_DOMAIN . split ( ":" , 1 ) [ 0 ] if hostname != canonical_hostname : if request . is_secure ( ) : canonical_url = "https://" else : canonical_url = "http://" canonical_url += SITE_DOMAIN + request . get_full_path ( ) return redirect ( canonical_url , permanent = True )
If the request domain is not the canonical domain, redirect.
If the request domain is not the canonical domain redirect .
"""If the request domain is not the canonical domain, redirect.""" # Don't perform redirection for testing or local development. # Check against the site domain.
self
request