cgi_main.py
author Tero Marttila <terom@fixme.fi>
Mon, 16 Feb 2009 19:08:17 +0200
changeset 78 a46d2fc07951
parent 66 d2ce81dd5e5d
permissions -rw-r--r--
add test for tree_parse filesystem stuff
#!/usr/bin/python2.5

"""
    Simple WSGI CGI handler using wsgiref.handlers
"""

import wsgiref.handlers

def error () :
    """
        Dumps out a raw traceback of the current exception to stdout, call from except
    """

    import traceback, sys
    
    # HTTP headers
    sys.stdout.write('Status: 500 Internal Server Error\r\n')
    sys.stdout.write('Content-type: text/plain\r\n')
    sys.stdout.write('\r\n')
    
    # exception traceback
    traceback.print_exc(100, sys.stdout)

def run (app) :
    """
        Run CGI request
    """

    # create handler
    cgi_handler = wsgiref.handlers.CGIHandler()

    # run once
    cgi_handler.run(app)