How to stop BaseHTTPServer.serve_forever() in a BaseHTTPRequestHandler subclass?

Another way to do it, based on http://docs.python.org/2/library/basehttpserver.html#more-examples, is: instead of serve_forever(), keep serving as long as a condition is met, with the server checking the condition before and after each request. For example: import CGIHTTPServer import BaseHTTPServer KEEP_RUNNING = True def keep_running(): return KEEP_RUNNING class Handler(CGIHTTPServer.CGIHTTPRequestHandler): cgi_directories = [“/cgi-bin”] httpd = BaseHTTPServer.HTTPServer((“”, 8000), Handler) … Read more

How to silent/quiet HTTPServer and BasicHTTPRequestHandler’s stderr output?

This will probably do it: from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header(‘Content-type’, ‘text/html’) self.end_headers() self.wfile.write(‘<html><body><p>OK</p></body></html>’) def log_message(self, format, *args): return httpd = HTTPServer((”, 8001), MyHandler) httpd.serve_forever()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)