Example #1
0
def serve(directory, port, preprocessor, verbose=True):
    server_address = ('', port)
    httpd = HTTPServer(server_address,
                       PreprocessingHTTPRequestHandler)
    httpd.preprocessor = preprocessor
    httpd.basepath = directory

    sa = httpd.socket.getsockname()

    if verbose:
        print("Serving HTTP on", sa[0], "port", sa[1], "...")

    httpd.serve_forever()