# -*- coding: utf-8 -*- import cgitb, tempfile, webbrowser, sys class MyHook(cgitb.Hook): def __init__(self): self.tmpFileName = '/tmp/test.html' self.tmpFile = open(self.tmpFileName, mode='w') cgitb.Hook.__init__(self, file=self.tmpFile) def handle(self, info=None): cgitb.Hook.handle(self, info) webbrowser.open(self.tmpFileName) sys.excepthook = MyHook() raise Exception('I am an exceptioän')