Fix http server with python 3.
This commit is contained in:
@@ -117,14 +117,13 @@ def build(source, destination, debug=False, verbose=False, force=False,
|
||||
def serve(path):
|
||||
"""Run a simple web server."""
|
||||
|
||||
import SimpleHTTPServer
|
||||
import SocketServer
|
||||
|
||||
if os.path.exists(path):
|
||||
from .compat import server, socketserver
|
||||
|
||||
os.chdir(path)
|
||||
PORT = 8000
|
||||
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
|
||||
httpd = SocketServer.TCPServer(("", PORT), Handler, False)
|
||||
Handler = server.SimpleHTTPRequestHandler
|
||||
httpd = socketserver.TCPServer(("", PORT), Handler, False)
|
||||
|
||||
print(" * Running on http://127.0.0.1:{}/".format(PORT))
|
||||
|
||||
|
||||
@@ -8,7 +8,13 @@ if not PY2:
|
||||
text_type = str
|
||||
string_types = (str,)
|
||||
unichr = chr
|
||||
|
||||
from http import server
|
||||
import socketserver
|
||||
else:
|
||||
text_type = unicode # NOQA
|
||||
string_types = (str, unicode) # NOQA
|
||||
unichr = unichr
|
||||
|
||||
import SimpleHTTPServer as server
|
||||
import SocketServer as socketserver
|
||||
|
||||
Reference in New Issue
Block a user