summaryrefslogtreecommitdiff
path: root/tools/http_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/http_server.py')
-rwxr-xr-xtools/http_server.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/http_server.py b/tools/http_server.py
index fdb8686cd..d33f24d5d 100755
--- a/tools/http_server.py
+++ b/tools/http_server.py
@@ -9,6 +9,7 @@ from util import root_path
from time import sleep
PORT = 4545
+REDIRECT_PORT = 4546
def server():
@@ -20,11 +21,35 @@ def server():
return s
+def redirect_server():
+ os.chdir(root_path)
+ target_host = "http://localhost:%d" % PORT
+
+ class RedirectHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ def do_GET(self):
+ self.send_response(301)
+ self.send_header('Location', target_host + self.path)
+ self.end_headers()
+
+ Handler = RedirectHandler
+ SocketServer.TCPServer.allow_reuse_address = True
+ s = SocketServer.TCPServer(("", REDIRECT_PORT), Handler)
+ print "Deno redirect server http://localhost:%d/ -> http://localhost:%d/" % (
+ REDIRECT_PORT, PORT)
+ return s
+
+
def spawn():
+ # Main http server
s = server()
thread = Thread(target=s.serve_forever)
thread.daemon = True
thread.start()
+ # Redirect server
+ rs = redirect_server()
+ r_thread = Thread(target=rs.serve_forever)
+ r_thread.daemon = True
+ r_thread.start()
sleep(1) # TODO I'm too lazy to figure out how to do this properly.
return thread