#!/usr/bin/python #import cgitb; cgitb.enable() txt_file = "crash_example_02.txt" def main(): print "Content-type: text/html" print print "Crashy Python Script" print "" print "

Demonstration of what happens when you crash in your python cgi script & strategies to write better, more robust and debuggable code.


" print "Key elements of this file:
" print "" print "unreachable text" print "" if( __name__ == "__main__"): try: main() except: print "

Uh oh! Something bad happened!

" print "

This message is generated in the 'except' block

" print ""