import sys class MyOutput: def write(self, text): # send to web server sys.stdout = MyOutput()