Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 706668 - Should be able to specify custom handler class for mozhttpd
Browse files Browse the repository at this point in the history
  • Loading branch information
William Lachance committed Dec 1, 2011
1 parent 92c1581 commit ad43f78
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mozhttpd/mozhttpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,24 @@ def log_message(self, format, *args):

class MozHttpd(object):

def __init__(self, host="127.0.0.1", port=8888, docroot=os.getcwd()):
def __init__(self, host="127.0.0.1", port=8888, docroot=os.getcwd(), handler_class=MozRequestHandler):
self.host = host
self.port = int(port)
self.docroot = docroot
self.httpd = None

class MozRequestHandlerInstance(handler_class):
docroot = self.docroot

self.handler_class = MozRequestHandlerInstance

def start(self, block=False):
"""
start the server. If block is True, the call will not return.
If block is False, the server will be started on a separate thread that
can be terminated by a call to .stop()
"""

class MozRequestHandlerInstance(MozRequestHandler):
docroot = self.docroot

self.httpd = EasyServer((self.host, self.port), MozRequestHandlerInstance)
self.httpd = EasyServer((self.host, self.port), self.handler_class)
if block:
self.httpd.serve_forever()
else:
Expand Down

0 comments on commit ad43f78

Please sign in to comment.