bin/index.cgi
changeset 143 154d2d8ae9c0
parent 142 e163794ccf54
child 144 35c4c56f1376
equal deleted inserted replaced
142:e163794ccf54 143:154d2d8ae9c0
     1 #!/usr/bin/python2.5
       
     2 
       
     3 """
       
     4     CGI mode using qmsk.web.cgi
       
     5 """
       
     6 
       
     7 def error () :
       
     8     """
       
     9         Dumps out a raw traceback of the current exception to stdout, call from except.
       
    10 
       
    11         Used for low-level ImportError's
       
    12     """
       
    13     
       
    14     import sys
       
    15 
       
    16     # if this import fails, we're doomed
       
    17     from qmsk.irclogs import error
       
    18     
       
    19     # format info
       
    20     status, content_type, body = error.build_error()
       
    21     
       
    22     # HTTP headers+body
       
    23     sys.stdout.write('Status: %s\r\n' % status)
       
    24     sys.stdout.write('Content-type: %s\r\n' % content_type)
       
    25     sys.stdout.write('\r\n')
       
    26     sys.stdout.write(body)
       
    27     
       
    28 def main () :
       
    29     """
       
    30         Build our wsgi.Application and run
       
    31     """
       
    32 
       
    33     try :
       
    34         from qmsk.web import cgi_main
       
    35         from qmsk.irclogs import wsgi
       
    36 
       
    37         # create app
       
    38         app = wsgi.Application()
       
    39         
       
    40         # run once
       
    41         cgi_main.run(app)
       
    42 
       
    43     except :
       
    44         # display error on stdout
       
    45         error()
       
    46     
       
    47 if __name__ == '__main__' :
       
    48     main()
       
    49