(environ=os.environ)
Robust test CGI script, usable as main program.

    Write minimal HTTP headers and dump all information provided to
    the script in HTML form.
Robust test CGI script, usable as main program.
Robust test CGI script usable as main program .
def test(environ=os.environ):
    """Robust test CGI script, usable as main program.

    Write minimal HTTP headers and dump all information provided to
    the script in HTML form.

    """
    print("Content-type: text/html")
    print()
    sys.stderr = sys.stdout
    try:
        form = FieldStorage()   # Replace with other classes to test those
        print_directory()
        print_arguments()
        print_form(form)
        print_environ(environ)
        print_environ_usage()
        def f():
            exec("testing print_exception() -- <I>italics?</I>")
        def g(f=f):
            f()
        print("<H3>What follows is a test, not an actual exception:</H3>")
        g()
    except:
        print_exception()

    print("<H1>Second try with a small maxlen...</H1>")

    global maxlen
    maxlen = 50
    try:
        form = FieldStorage()   # Replace with other classes to test those
        print_directory()
        print_arguments()
        print_form(form)
        print_environ(environ)
    except:
        print_exception()
def test ( environ = os . environ ) : print ( "Content-type: text/html" ) print ( ) sys . stderr = sys . stdout try : form = FieldStorage ( ) # Replace with other classes to test those print_directory ( ) print_arguments ( ) print_form ( form ) print_environ ( environ ) print_environ_usage ( ) def f ( ) : exec ( "testing print_exception() -- <I>italics?</I>" ) def g ( f = f ) : f ( ) print ( "<H3>What follows is a test, not an actual exception:</H3>" ) g ( ) except : print_exception ( ) print ( "<H1>Second try with a small maxlen...</H1>" ) global maxlen maxlen = 50 try : form = FieldStorage ( ) # Replace with other classes to test those print_directory ( ) print_arguments ( ) print_form ( form ) print_environ ( environ ) except : print_exception ( )