66
|
1 |
#!/usr/bin/python2.5
|
|
2 |
|
|
3 |
"""
|
|
4 |
Simple WSGI CGI handler using wsgiref.handlers
|
|
5 |
"""
|
|
6 |
|
|
7 |
import wsgiref.handlers
|
|
8 |
|
|
9 |
def error () :
|
|
10 |
"""
|
|
11 |
Dumps out a raw traceback of the current exception to stdout, call from except
|
|
12 |
"""
|
|
13 |
|
|
14 |
import traceback, sys
|
|
15 |
|
|
16 |
# HTTP headers
|
|
17 |
sys.stdout.write('Status: 500 Internal Server Error\r\n')
|
|
18 |
sys.stdout.write('Content-type: text/plain\r\n')
|
|
19 |
sys.stdout.write('\r\n')
|
|
20 |
|
|
21 |
# exception traceback
|
|
22 |
traceback.print_exc(100, sys.stdout)
|
|
23 |
|
|
24 |
def run (app) :
|
|
25 |
"""
|
|
26 |
Run CGI request
|
|
27 |
"""
|
|
28 |
|
|
29 |
# create handler
|
|
30 |
cgi_handler = wsgiref.handlers.CGIHandler()
|
|
31 |
|
|
32 |
# run once
|
|
33 |
cgi_handler.run(app)
|
|
34 |
|