def host_from_uri(uri):
 default_ports = {u'HTTP': u'80', u'HTTPS': u'443'}
 (sch, netloc, path, par, query, fra) = urlparse.urlparse(uri)
 if (u':' in netloc):
  (netloc, port) = netloc.split(u':', 1)
 else:
  port = default_ports.get(sch.upper())
 return (netloc, port)

def host_from_uri ( uri ) : default_ports = { u'HTTP' : u'80' , u'HTTPS' : u'443' } ( sch , netloc , path , par , query , fra ) = urlparse . urlparse ( uri ) if ( u':' in netloc ) : ( netloc , port ) = netloc . split ( u':' , 1 ) else : port = default_ports . get ( sch . upper ( ) ) return ( netloc , port )
extract hostname and port from uri .