<commit_before>from sheared.python.application import Application
from sheared.web.server import HTTPServer
from sheared.web.virtualhost import VirtualHost
from sheared import reactor

webserver_options = [
    ['set_str', 1, 'interface', '', 'interface', 'webserver.interface',
     'Bind web server to this interface.'],

    ['set_int', 1, 'port', '', 'port', 'webserver.port',
     'Bind web server to this port.'],

    ['set_str', 1, 'hostname', '', 'hostname', 'webserver.hostname',
     'Externally visible name of web server.'],
]

class WebserverApplication(Application):
    def __init__(self, name='webserver', options=[]):
        self.port = 80
        self.interface = ''
        self.hostname = 'localhost'

        opts = []
        opts.extend(webserver_options)
        opts.extend(options)

        Application.__init__(self, name, opts)

    def configure(self):
        raise NotImplementedError

    def setup(self):
        if self.port == 80:
            l = 'http://%s/' % self.hostname
        else:
            l = 'http://%s:%d/' % (self.hostname, self.port)
        self.root = self.configure()
        self.vhost = VirtualHost(self.root, l)

        self.webserver = HTTPServer()
        self.webserver.addVirtualHost(self.hostname, self.vhost)
        self.webserver.setDefaultHost(self.hostname)

        reactor.listenTCP(self.webserver, (self.interface, self.port))<commit_msg>Use new reactor.listen.<commit_after>from sheared.python.application import Application
from sheared.web.server import HTTPServer
from sheared.web.virtualhost import VirtualHost
from sheared import reactor

webserver_options = [
    ['set_str', 1, 'address', '', 'bind', 'webserver.bind',
     'Bind web server to this place.'],

    ['set_str', 1, 'hostname', '', 'hostname', 'webserver.hostname',
     'Externally visible name of web server.'],
]

class WebserverApplication(Application):
    def __init__(self, name='webserver', options=[]):
        self.port = 80
        self.interface = ''
        self.hostname = 'localhost'

        opts = []
        opts.extend(webserver_options)
        opts.extend(options)

        Application.__init__(self, name, opts)

    def configure(self):
        raise NotImplementedError

    def setup(self):
        if self.port == 80:
            l = 'http://%s/' % self.hostname
        else:
            l = 'http://%s:%d/' % (self.hostname, self.port)
        self.root = self.configure()
        self.vhost = VirtualHost(self.root, l)

        self.webserver = HTTPServer()
        self.webserver.addVirtualHost(self.hostname, self.vhost)
        self.webserver.setDefaultHost(self.hostname)

        reactor.listen(self.webserver, self.address)
{'fraction_non_alphanumeric': 0.13355530891601924, 'fraction_numerical': 0.004809470958194599, 'mean_word_length': 2.8573466476462195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5599753', 'n_tokens_mistral': 807, 'n_tokens_neox': 795, 'n_words': 183}