try: server = HTTPServer(('', 80), MyHandler) print 'Welcome to the machine...', print 'Press ^C once or twice to quit.' server.serve_forever() except KeyboardInterrupt: print '^C received, shutting down server' server.socket.close()
Related Scripts with Example Source Code in same category :