def get_url(host, pre_protocol=None):
    """Generate URL based on the host.

    :param str host: Host from which to generate the URL (e.g. google.com:443).
    :param str pre_protocol: Protocol passed in the GET Path. Example request:
        GET https://127.0.0.1/robots.txt HTTP/1.1
        Host: 127.0.0.1:323
        Then, pre_protocol will be `https`.
        Defaults to `None`.

    :return: URL with domain and protocol (e.g. https://google.com).
    :rtype: str
    """
    port_protocol = {'443': 'https', '22': 'ssh', '21': 'ftp', '20': 'ftp',
        '113': 'irc', '80': 'http'}
    protocol = ''
    url = host.strip()
    if not url.startswith('['):
        if ':' in url:
            _, port = url.rsplit(':', 1)
            if port in port_protocol:
                protocol = port_protocol[port] + '://'
    elif not url.endswith(']'):
        _, port = url.rsplit(':', 1)
        if port in port_protocol:
            protocol = port_protocol[port] + '://'
    protocol = pre_protocol or protocol or 'http://'
    return protocol + url
