2018-08-15 19:08:03 -04:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
|
2018-09-25 21:39:04 -04:00
|
|
|
def server():
|
2018-08-15 19:08:03 -04:00
|
|
|
os.chdir(root_path) # Hopefully the main thread doesn't also chdir.
|
|
|
|
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
|
2018-08-23 20:03:45 -04:00
|
|
|
SocketServer.TCPServer.allow_reuse_address = True
|
2018-09-25 21:39:04 -04:00
|
|
|
s = SocketServer.TCPServer(("", PORT), Handler)
|
2018-08-15 19:08:03 -04:00
|
|
|
print "Deno test server http://localhost:%d/" % PORT
|
2018-09-25 21:39:04 -04:00
|
|
|
return s
|
2018-08-15 19:08:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
def spawn():
|
2018-09-25 21:39:04 -04:00
|
|
|
s = server()
|
|
|
|
thread = Thread(target=s.serve_forever)
|
2018-08-15 19:08:03 -04:00
|
|
|
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__':
|
2018-09-25 21:39:04 -04:00
|
|
|
s = server()
|
|
|
|
s.serve_forever()
|