Fix http server with python 3.

This commit is contained in:
Simon Conseil
2014-01-03 00:24:38 +01:00
parent d97ad24ccf
commit 0db6af840d
2 changed files with 10 additions and 5 deletions

View File

@@ -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))

View File

@@ -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