diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-22 23:19:36 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-22 23:19:36 -0500 |
| commit | 070b5e6d9d3c7e23c06f0ae0b75026923529c24d (patch) | |
| tree | 89c430dd17ca54ff60f885ecd99cf6cfa0f0b7ff /cgi-bin/proxy | |
| parent | 04537ed34d443d0610b77420d1dbef64bc05fbfa (diff) | |
| parent | 1631cdf643283fc71bc9d70b5dcbce03ab9c2386 (diff) | |
Merge branch 'master' of lmno:dither
Diffstat (limited to 'cgi-bin/proxy')
| -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() + |
