diff --git a/src/scriptform.py b/src/scriptform.py index 4a7b2bd..acb158b 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -165,6 +165,7 @@ class ScriptForm: self.callbacks = {} self.basepath = os.path.realpath(os.path.dirname(config_file)) self.log = logging.getLogger('SCRIPTFORM') + self.websrv = None def get_form_config(self): """ @@ -217,7 +218,9 @@ class ScriptForm: Ctrl-c. """ ScriptFormWebApp.scriptform = self - WebSrv(ScriptFormWebApp, listen_addr=listen_addr, listen_port=listen_port) + self.httpd = ThreadedHTTPServer((listen_addr, listen_port), ScriptFormWebApp) + self.log.info("Listening on {0}:{1}".format(listen_addr, listen_port)) + self.httpd.serve_forever() class FormConfig: @@ -499,17 +502,6 @@ class ThreadedHTTPServer(ThreadingMixIn, BaseHTTPServer.HTTPServer): pass -class WebSrv: - """ - Very basic web server. - """ - def __init__(self, request_handler, listen_addr='', listen_port=80): - self.log = logging.getLogger('WEBSRV') - httpd = ThreadedHTTPServer((listen_addr, listen_port), request_handler) - self.log.info("Listening on {0}:{1}".format(listen_addr, listen_port)) - httpd.serve_forever() - - class WebAppHandler(BaseHTTPRequestHandler): """ Basic web server request handler. Handles GET and POST requests. This class