def extract_subdomain(host=None, base_domain=None):
 if (host is None):
  host = request.host
 if (base_domain is None):
  base_domain = g.domain
 if (not host):
  return ''
 end_index = (host.find(base_domain) - 1)
 if (end_index < 0):
  return ''
 return host[:end_index]

def extract_subdomain ( host = None , base_domain = None ) : if ( host is None ) : host = request . host if ( base_domain is None ) : base_domain = g . domain if ( not host ) : return '' end_index = ( host . find ( base_domain ) - 1 ) if ( end_index < 0 ) : return '' return host [ : end_index ]
try to extract a subdomain from the request .