diff options
| author | Jules <jules@asdf.us> | 2014-02-09 08:52:31 -0500 |
|---|---|---|
| committer | Jules <jules@asdf.us> | 2014-02-09 08:52:31 -0500 |
| commit | a4d0b65dcaf504796d1bc0beef87a592cd26265e (patch) | |
| tree | 9f2eb56b9adc6b5ac5145fd1f1b7d2c53a2ef39f | |
| parent | 3c3c7c840c872ece445ff74eb3095f9f11d4b8d8 (diff) | |
cgi-bin/proxy ... fix https urls
| -rwxr-xr-x | cgi-bin/proxy | 26 |
1 files changed, 26 insertions, 0 deletions
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() + |
