import sys import os import time import cStringIO import pprint import

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
import os
import time
import cStringIO
import pprint
import nginx_module
def application(environ, start_response):
input = environ['wsgi.input']
log = environ['wsgi.errors']
log.write('hello nginx log!, by mod_wsgi\n')
log.writelines(['line a', 'line b'])
result = ['Hello nginx!, by mod_wsgi']
result.append('Input:')
result.append(input.read())
buf = cStringIO.StringIO()
pprint.pprint(environ, stream=buf)
result.append('Environment:')
result.append(buf.getvalue())
buf = cStringIO.StringIO()
pprint.pprint(os.environ, stream=buf)
result.append('OS Environment:')
result.append(buf.getvalue())
result.append('sys.argv:')
result.extend(sys.argv)
result.append('sys.path:')
result.extend(sys.path)
result.append('pid:')
result.append('%d' % os.getpid())
headers = [
('Server', 'Test'),
('Content-Type', 'text/plain'),
('X-Powered-By', 'Python'),
#('Connection', 'close')
]
start_response('200 OK', headers)
return ['\n'.join(result)]