def start_http_server(): server_address = ('localhost', 0) httpd = BaseHTTPServer.HTTPServer(server_address, QuietHandler) sa = httpd.socket.getsockname() # print("Serving HTTP on", sa[0], "port", sa[1], "...") httpd.request_count = 0 def serve(): # increment the request_count before handling the request because # the send() for the response blocks (or at least appeared to be) httpd.request_count += 1 httpd.handle_request() return eventlet.spawn(serve), httpd, sa[1]
def start_http_server(): server_address = ('', port) BaseHTTPServer.BaseHTTPRequestHandler.protocol_version = "HTTP/1.0" httpd = BaseHTTPServer.HTTPServer(server_address, BaseHTTPServer.BaseHTTPRequestHandler) sa = httpd.socket.getsockname() #print "Serving HTTP on", sa[0], "port", sa[1], "..." httpd.request_count = 0 def serve(): httpd.handle_request() httpd.request_count += 1 return spawn(serve), httpd