Last active
July 4, 2016 09:17
-
-
Save grav/ad389981e0d7c1dd79ef0567760ce54b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SimpleHTTPServer | |
import SocketServer | |
import urllib | |
import re | |
class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
match = re.search('^/proxy.ashx?\?url=(.+)$',self.path) | |
if match: | |
self.send_response(200) | |
self.end_headers() | |
url = match.group(1) | |
print url | |
self.copyfile(urllib.urlopen(url), self.wfile) | |
else: | |
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | |
PORT = 8001 | |
httpd = SocketServer.TCPServer(("", PORT), Proxy) | |
print "serving at port", PORT | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proxy certain requests, otherwise just load from disk