diff options
-rw-r--r-- | tests/server.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/server.py b/tests/server.py index 6a32a2d..aa895ea 100644 --- a/tests/server.py +++ b/tests/server.py @@ -4,9 +4,9 @@ """ server.py ~~~~~~~~~ - + test server - + :copyright: (c) 2013 by Jauhien Piatlicki :license: GPL-2, see LICENSE for more details. """ @@ -18,7 +18,7 @@ import time from g_sorcery.compatibility import py2k if py2k: - from SocketServer import TCPServer as HTTPServer + from SocketServer import TCPServer as HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler else: from http.server import HTTPServer @@ -27,24 +27,24 @@ else: def HTTPRequestHandlerGenerator(direct): class HTTPRequestHandler(SimpleHTTPRequestHandler, object): - directory = direct def __init__(self, request, client_address, server): + self.direct = direct super(HTTPRequestHandler, self).__init__(request, client_address, server) def translate_path(self, path): - return os.path.join(self.directory, path[1:]) + return os.path.join(self.direct, path[1:]) return HTTPRequestHandler - + class Server(threading.Thread): def __init__(self, directory, port=8080): super(Server, self).__init__() HTTPServer.allow_reuse_address = True server_address = ('127.0.0.1', port) self.httpd = HTTPServer(server_address, HTTPRequestHandlerGenerator(directory)) - + def run(self): self.httpd.serve_forever() |