Determine the server URL.

def site_url(url):
    """
    Determine the server URL.
    """
    base_url = 'http://%s' % socket.gethostname()

    if server.port is not 80:
        base_url += ':%d' % server.port

    return urlparse.urljoin(base_url, url)