summaryrefslogtreecommitdiff
path: root/bin/proxy.py
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2014-02-02 19:09:21 -0500
committerjules <jules@okfoc.us>2014-02-02 19:09:21 -0500
commite40466465b88c6d9be39e11f1200d1a044b6d133 (patch)
tree24eb9585cad09e871292a5ef2a0566cd741f8a54 /bin/proxy.py
parentb125e3106727e0acb627f17f4de0a1c3a1cf6f49 (diff)
point at proper upload endpoint
Diffstat (limited to 'bin/proxy.py')
-rwxr-xr-xbin/proxy.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/proxy.py b/bin/proxy.py
index 6171dab..b44bbbc 100755
--- a/bin/proxy.py
+++ b/bin/proxy.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
import http.server
import urllib.request
+import re
-class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
+class MyHTTPRequestHandler(http.server.CGIHTTPRequestHandler ):
def end_headers(self):
self.send_my_headers()
- http.server.SimpleHTTPRequestHandler.end_headers(self)
+ http.server.CGIHTTPRequestHandler .end_headers(self)
def send_my_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
@@ -14,9 +15,17 @@ class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path[0:14] == "/cgi-bin/proxy":
self.copyfile(urllib.request.urlopen(self.path[15:]), self.wfile)
+ elif re.match(r'.+cgi-bin/im/shader/.+$', self.path):
+ self.path = re.sub(r'(.+cgi-bin/)im/shader/(.+)$', r'\1\2', self.path);
+ super().do_GET();
else:
super().do_GET()
+ def do_POST(self):
+ if re.match(r'.+cgi-bin/im/shader/.+$', self.path):
+ self.path = re.sub(r'(.+cgi-bin/)im/shader/(.+)$', r'\1\2', self.path);
+ super().do_POST();
+
if __name__ == '__main__':
http.server.test(HandlerClass=MyHTTPRequestHandler)