Demo entry 6717640

Python Proxy


Submitted by anonymous on Feb 26, 2018 at 22:06
Language: Python 3. Code size: 784 Bytes.

def proxy_get():
    target_url = unquote(request.args.get('target'))
        headers = json.loads(unquote(request.args.get('headers'))) or {}
    except Exception as e:
        return Response("ERROR: invalid headers param: " + e, status=400)

    if target_url:
        response = requests.get(url=target_url, headers=headers)
        if response.status_code == 200:
            content_type = response.headers.get('Content-Type')
            return Response(response.content, content_type=content_type, mimetype=content_type, status=200)
            return Response("ERROR: request returned status of {}".format(response.status_code), status=400)
        return Response("ERROR: missing target param", status=400)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).