import sys import cgi import traceback print "Content-type: text/html" print sys.stderr = sys.stdout try: n = 10 while n>0: print "<hr>" print 10/(n-1) # This will cause an error when n=1 n = n - 1 except: print "\n\n<PRE>" traceback.print_exc()