I have the following simple Threaded fileserver to be used by my application:
class FileServer(Thread):
"""Simple file server exposing the current directory for the thumbnail
creator
"""
def __init__(self, port):
Thread.__init__(self)
self.port = port
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
self.httpd = SocketServer.TCPServer(("", port), Handler)
def run(self):
self.httpd.serve_forever()
def stop(self):
self.httpd.shutdown()
How can I prevent SimpleHTTPServer to output "GET 'http:// BLA BLA BLA" at every request? Thanks
You can subclass
SimpleHTTPServer.SimpleHTTPRequestHandler
and override thelog_message
method. Here is the method you will be overriding, sans docstring:So to simply ignore all messages, replace the body of the function with
pass
. For more fine-grained control (i.e if you still want error messages printed), you may instead override thelog_request
and/orlog_error
methods. Original methods are like this:From 2.7 to 3.1 the module names change, but these methods are unchanged.