Returns a subdomain from a host. This host is typically the
        HTTP_HOST request envvar.  If the host is an IP address, `None` is
        returned

        :param host: Request's target host

def _extract_subdomain(host):
        """ Returns a subdomain from a host. This host is typically the
        HTTP_HOST request envvar.  If the host is an IP address, `None` is
        returned

        :param host: Request's target host
        """
        host = host.split(':')[0]
        # If the host is an IP address, there is no subdomain to extract
        try:
            # Check if the host is an ip address
            socket.inet_aton(host)
        except socket.error:
            # It isn't an IP address, return the subdomain
            return '.'.join(host.split('.')[:-2])