def construct_url(url, size=None, external=False):
    from redwind.models import get_settings
    if not url or 'PILBOX_URL' not in current_app.config:
        return url
    url = urllib.parse.urljoin(get_settings().site_url, url)
    query = [('url', url)]
    if size:
        query += [('w', size), ('h', size), ('mode', 'clip')]
    else:
        query += [('op', 'noop')]
    querystring = urllib.parse.urlencode(query)
    if 'PILBOX_KEY' in current_app.config:
        h = hmac.new(current_app.config['PILBOX_KEY'].encode(),
                     querystring.encode(), hashlib.sha1)
        querystring += '&sig=' + h.hexdigest()
    proxy_url = current_app.config['PILBOX_URL'] + '?' + querystring
    if external:
        proxy_url = urllib.parse.urljoin(get_settings().site_url, proxy_url)
    return proxy_url
dataset/ETHPy150Open kylewm/redwind/redwind/imageproxy.py/construct_url/original