code: def _get_base_url(request):
      
      if request.is_secure():
          base_url = 'https://%s'
      else:
          base_url = 'http://%s'
      base_url %= request.META['HTTP_HOST']
      return base_url
docs: Construct a base URL, given a request object.
  
      This comprises the protocol prefix (http:// or https://) and the host,
      which can include the port number. For example:
      http://www.openquake.org or https://www.openquake.org:8000.