code: def baseurl(url):
      
      parsed_url = urlparse.urlparse(url)
      if not parsed_url.netloc or parsed_url.scheme not in ("http", "https"):
          raise ValueError('bad url')
      service_url = "%s://%s%s" % (parsed_url.scheme, parsed_url.netloc, parsed_url.path.strip())
      return service_url
docs: return baseurl of given url