on unixpython cgi programs may require appropriate execute permissions to be set and line such as the following to appear as the first line of the program#!/usr/bin/env python import cgi to simplify debuggingimport the cgitb module--for exampleimport cgitbcgitb enable(this modifies exception handling so that errors are displayed in the web browser if you invoke an external program--for examplevia the os system(or os popen(function--be careful not to pass arbitrary strings received from the client to the shell this is well-known security hole that hackers can use to execute arbitrary shell commands on the server (because the command passed to these functions is first interpreted by the unix shell as opposed to being executed directlyin particularnever pass any part of url or form data to shell command unless it has first been thoroughly checked by making sure that the string contains only alphanumeric charactersdashesunderscoresand periods on unixdon' give cgi program setuid mode this is security liability and not supported on all machines don' use 'from cgi import *with this module the cgi module defines wide variety of names and symbols that you probably don' want in your namespace cgitb this module provides an alternative exception handler that displays detailed report whenever an uncaught exception occurs the report contains source codevalues of parametersand local variables originallythis module was developed to help debug cgi scriptsbut it can be used in any application enable([display [logdir [context [format]]]]enables special exception handling display is flag that determines whether any information is displayed when an error occurs the default value is logdir specifies directory in which error reports will be written to files instead of printed to standard output when logdir is giveneach error report is written to unique file created by the tempfile mkstemp(function context is an integer specifying the number of lines of source code to display around lines upon which the exception occurred format is string that specifies the output format format of 'htmlspecifies html (the defaultany other value results in plain-text format handle([info]handles an exception using the default settings of the enable(function info is tuple (exctypeexcvaluetbwhere exctype is an exception typeexcvalue is an exception valueand tb is traceback object this tuple is normally obtained using sys exc_info(if info is omittedthe current exception is used lib fl ff