From a4d0b65dcaf504796d1bc0beef87a592cd26265e Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 9 Feb 2014 08:52:31 -0500 Subject: cgi-bin/proxy ... fix https urls --- cgi-bin/proxy | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 cgi-bin/proxy (limited to 'cgi-bin') diff --git a/cgi-bin/proxy b/cgi-bin/proxy new file mode 100755 index 0000000..9c2ca3d --- /dev/null +++ b/cgi-bin/proxy @@ -0,0 +1,26 @@ +#!/usr/bin/python + +from os import environ as env +import urllib.request +import sys + +def error(): + print("Content-type: text/html") + print() + print("HELLO!") + +def proxy(url,ext): + req = urllib.request.urlopen(url) + print("Content-type: image/" + ext) + print() + sys.stdout.flush() + sys.stdout.buffer.write( req.read() ) + +path = env['QUERY_STRING'] +ext = path[-3:].lower() + +if path[0:4] == "http" and ext in ("gif","jpg","png","peg"): + proxy(path,ext) +else: + error() + -- cgit v1.2.3-70-g09d2