summaryrefslogtreecommitdiff
path: root/cgi-bin/proxy
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-22 23:19:36 -0500
committerJules Laplace <jules@okfoc.us>2014-11-22 23:19:36 -0500
commit070b5e6d9d3c7e23c06f0ae0b75026923529c24d (patch)
tree89c430dd17ca54ff60f885ecd99cf6cfa0f0b7ff /cgi-bin/proxy
parent04537ed34d443d0610b77420d1dbef64bc05fbfa (diff)
parent1631cdf643283fc71bc9d70b5dcbce03ab9c2386 (diff)
Merge branch 'master' of lmno:dither
Diffstat (limited to 'cgi-bin/proxy')
-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()
+