Python six.moves.BaseHTTPServer.BaseHTTPRequestHandler() Examples

The following are 17 code examples of six.moves.BaseHTTPServer.BaseHTTPRequestHandler(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module six.moves.BaseHTTPServer , or try the search function .
Example #1
Source File: handler.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def log_request(self, *args):
    """Does nothing."""
    # This is called by BaseHTTPRequestHandler.send_response() which causes it
    # to log every request. We've configured http.Respond() to only log
    # requests with >=400 status code.
    pass 
Example #2
Source File: handler.py    From keras-lambda with MIT License 5 votes vote down vote up
def log_request(self, *args):
    """Does nothing."""
    # This is called by BaseHTTPRequestHandler.send_response() which causes it
    # to log every request. We've configured http.Respond() to only log
    # requests with >=400 status code.
    pass 
Example #3
Source File: handler.py    From keras-lambda with MIT License 5 votes vote down vote up
def log_message(self, *args):
    """Logs message."""
    # By default, BaseHTTPRequestHandler logs to stderr.
    logging.info(*args)

  # @Override 
Example #4
Source File: handler.py    From keras-lambda with MIT License 5 votes vote down vote up
def __init__(self, multiplexer, name_to_plugin_dict, logdir, *args):
    self._multiplexer = multiplexer
    self._registered_plugins = name_to_plugin_dict
    self._logdir = logdir
    self._setup_data_handlers()
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) 
Example #5
Source File: THttpServer.py    From thrift with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 processor,
                 server_address,
                 inputProtocolFactory,
                 outputProtocolFactory=None,
                 server_class=BaseHTTPServer.HTTPServer):
        if outputProtocolFactory is None:
            outputProtocolFactory = inputProtocolFactory
        TServer.TServer.__init__(self, processor, None, None, None,
                                 inputProtocolFactory, outputProtocolFactory)
        thttpserver = self
        class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
            def do_POST(self):
                itrans = TTransport.TFileObjectTransport(self.rfile)
                otrans = TTransport.TFileObjectTransport(self.wfile)
                itrans = TTransport.TBufferedTransport(
                    itrans, int(self.headers['Content-Length']))
                otrans = TTransport.TMemoryBuffer()
                iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
                oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
                try:
                    thttpserver.processor.process(iprot, oprot)
                except ResponseException as exn:
                    exn.handler(self)
                else:
                    self.send_response(200)
                    self.send_header("content-type", "application/x-thrift")
                    self.end_headers()
                    self.wfile.write(otrans.getvalue())
        self.httpd = server_class(server_address, RequestHander) 
Example #6
Source File: THttpServer.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 processor,
                 server_address,
                 inputProtocolFactory,
                 outputProtocolFactory=None,
                 server_class=BaseHTTPServer.HTTPServer):
        if outputProtocolFactory is None:
            outputProtocolFactory = inputProtocolFactory
        TServer.TServer.__init__(self, processor, None, None, None,
                                 inputProtocolFactory, outputProtocolFactory)
        thttpserver = self
        class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
            def do_POST(self):
                itrans = TTransport.TFileObjectTransport(self.rfile)
                otrans = TTransport.TFileObjectTransport(self.wfile)
                itrans = TTransport.TBufferedTransport(
                    itrans, int(self.headers['Content-Length']))
                otrans = TTransport.TMemoryBuffer()
                iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
                oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
                try:
                    thttpserver.processor.process(iprot, oprot)
                except ResponseException as exn:
                    exn.handler(self)
                else:
                    self.send_response(200)
                    self.send_header("content-type", "application/x-thrift")
                    self.end_headers()
                    self.wfile.write(otrans.getvalue())
        self.httpd = server_class(server_address, RequestHander) 
Example #7
Source File: THttpServer.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 processor,
                 server_address,
                 inputProtocolFactory,
                 outputProtocolFactory=None,
                 server_class=BaseHTTPServer.HTTPServer):
        """Set up protocol factories and HTTP server.

        See BaseHTTPServer for server_address.
        See TServer for protocol factories.
        """
        if outputProtocolFactory is None:
            outputProtocolFactory = inputProtocolFactory

        TServer.TServer.__init__(self, processor, None, None, None,
                                 inputProtocolFactory, outputProtocolFactory)

        thttpserver = self

        class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
            def do_POST(self):
                # Don't care about the request path.
                itrans = TTransport.TFileObjectTransport(self.rfile)
                otrans = TTransport.TFileObjectTransport(self.wfile)
                itrans = TTransport.TBufferedTransport(
                    itrans, int(self.headers['Content-Length']))
                otrans = TTransport.TMemoryBuffer()
                iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
                oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
                try:
                    thttpserver.processor.process(iprot, oprot)
                except ResponseException as exn:
                    exn.handler(self)
                else:
                    self.send_response(200)
                    self.send_header("content-type", "application/x-thrift")
                    self.end_headers()
                    self.wfile.write(otrans.getvalue())

        self.httpd = server_class(server_address, RequestHander) 
Example #8
Source File: kmeans_labeler_request_handler.py    From moonlight with Apache License 2.0 5 votes vote down vote up
def __init__(self, clusters, output_path, *args):
    self.clusters = clusters
    self.output_path = output_path
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) 
Example #9
Source File: THttpServer.py    From Aditmadzs2 with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 processor,
                 server_address,
                 inputProtocolFactory,
                 outputProtocolFactory=None,
                 server_class=BaseHTTPServer.HTTPServer):
        """Set up protocol factories and HTTP server.

        See BaseHTTPServer for server_address.
        See TServer for protocol factories.
        """
        if outputProtocolFactory is None:
            outputProtocolFactory = inputProtocolFactory

        TServer.TServer.__init__(self, processor, None, None, None,
                                 inputProtocolFactory, outputProtocolFactory)

        thttpserver = self

        class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
            def do_POST(self):
                # Don't care about the request path.
                itrans = TTransport.TFileObjectTransport(self.rfile)
                otrans = TTransport.TFileObjectTransport(self.wfile)
                itrans = TTransport.TBufferedTransport(
                    itrans, int(self.headers['Content-Length']))
                otrans = TTransport.TMemoryBuffer()
                iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
                oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
                try:
                    thttpserver.processor.process(iprot, oprot)
                except ResponseException as exn:
                    exn.handler(self)
                else:
                    self.send_response(200)
                    self.send_header("content-type", "application/x-thrift")
                    self.end_headers()
                    self.wfile.write(otrans.getvalue())

        self.httpd = server_class(server_address, RequestHander) 
Example #10
Source File: handler.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def __init__(self, multiplexer, name_to_plugin_dict, logdir, *args):
    self._multiplexer = multiplexer
    self._registered_plugins = name_to_plugin_dict
    self._logdir = logdir
    self._setup_data_handlers()
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) 
Example #11
Source File: handler.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def log_message(self, *args):
    """Logs message."""
    # By default, BaseHTTPRequestHandler logs to stderr.
    logging.info(*args)

  # @Override 
Example #12
Source File: handler.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def __init__(self, multiplexer, logdir, *args):
    self._multiplexer = multiplexer
    self._logdir = logdir
    self._setup_data_handlers()
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) 
Example #13
Source File: THttpServer.py    From Protect4 with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 processor,
                 server_address,
                 inputProtocolFactory,
                 outputProtocolFactory=None,
                 server_class=BaseHTTPServer.HTTPServer):
        """Set up protocol factories and HTTP server.

        See BaseHTTPServer for server_address.
        See TServer for protocol factories.
        """
        if outputProtocolFactory is None:
            outputProtocolFactory = inputProtocolFactory

        TServer.TServer.__init__(self, processor, None, None, None,
                                 inputProtocolFactory, outputProtocolFactory)

        thttpserver = self

        class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
            def do_POST(self):
                # Don't care about the request path.
                itrans = TTransport.TFileObjectTransport(self.rfile)
                otrans = TTransport.TFileObjectTransport(self.wfile)
                itrans = TTransport.TBufferedTransport(
                    itrans, int(self.headers['Content-Length']))
                otrans = TTransport.TMemoryBuffer()
                iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
                oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
                try:
                    thttpserver.processor.process(iprot, oprot)
                except ResponseException as exn:
                    exn.handler(self)
                else:
                    self.send_response(200)
                    self.send_header("content-type", "application/x-thrift")
                    self.end_headers()
                    self.wfile.write(otrans.getvalue())

        self.httpd = server_class(server_address, RequestHander) 
Example #14
Source File: server.py    From testplan with Apache License 2.0 5 votes vote down vote up
def get_options(cls):
        """
        Schema for options validation and assignment of default values.
        """
        return {
            Optional("host", default="localhost"): str,
            Optional("port", default=0): Use(int),
            Optional(
                "request_handler", default=HTTPRequestHandler
            ): lambda v: issubclass(v, http_server.BaseHTTPRequestHandler),
            Optional("handler_attributes", default={}): dict,
            Optional("timeout", default=5): Use(int),
            Optional("interval", default=0.01): Use(float),
        } 
Example #15
Source File: server.py    From testplan with Apache License 2.0 5 votes vote down vote up
def log_message(self, format, *args):
        """Log messages from the BaseHTTPRequestHandler class."""
        self.server.log_callback("BASE CLASS: {}".format(format % args)) 
Example #16
Source File: handler.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def log_request(self, *args):
    """Does nothing."""
    # This is called by BaseHTTPRequestHandler.send_response() which causes it
    # to log every request. We've configured http.Respond() to only log
    # requests with >=400 status code.
    pass 
Example #17
Source File: handler.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def log_message(self, *args):
    """Logs message."""
    # By default, BaseHTTPRequestHandler logs to stderr.
    logging.info(*args)

  # @Override