Esempio n. 1
0
    def __init__(self, host, port, root, whitelist):
        """Create a server that serves from root on host:port.

        Only paths in the root directory that are also present in the whitelist
        will be served. The whitelist paths are absolute, so they must begin
        with a slash. The paths '/', '/index.html', and '/404.html' must be
        included for the website to work properly.
        """
        self.httpd = pywsgi.WSGIServer((host, port), self.handle_request)
        self.url = "http://{}:{}".format(host, port)
        self.root = root.rstrip('/')
        self.whitelist = whitelist
        self.running = False
        self.controller = Controller()