summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2014-02-09 19:31:52 -0500
committerjules <jules@okfoc.us>2014-02-09 19:31:52 -0500
commit2654146c9af10297066e6710f9aab69af40c74f6 (patch)
tree05aede0b65f7d5b2967f2da4ac5f19dc9c5ec583
parent0c98634db0fe74b8fe7bb18804db91a9c3c59803 (diff)
parenta4d0b65dcaf504796d1bc0beef87a592cd26265e (diff)
Merge branch 'master' of lmno:dither
-rwxr-xr-xcgi-bin/proxy26
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()
+