diff options
Diffstat (limited to 'tools/http_server.py')
-rwxr-xr-x | tools/http_server.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/http_server.py b/tools/http_server.py new file mode 100755 index 000000000..a3e6adf44 --- /dev/null +++ b/tools/http_server.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# Many tests expect there to be an http server on port 4545 servering the deno +# root directory. +import os +from threading import Thread +import SimpleHTTPServer +import SocketServer +from util import root_path +from time import sleep + +PORT = 4545 + + +def serve_forever(): + os.chdir(root_path) # Hopefully the main thread doesn't also chdir. + Handler = SimpleHTTPServer.SimpleHTTPRequestHandler + httpd = SocketServer.TCPServer(("", PORT), Handler) + print "Deno test server http://localhost:%d/" % PORT + httpd.serve_forever() + + +def spawn(): + thread = Thread(target=serve_forever) + thread.daemon = True + thread.start() + sleep(1) # TODO I'm too lazy to figure out how to do this properly. + return thread + + +if __name__ == '__main__': + serve_forever() |