-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathwsgitest.py
More file actions
53 lines (41 loc) · 1.51 KB
/
wsgitest.py
File metadata and controls
53 lines (41 loc) · 1.51 KB
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
import sys
def application(env, start_response):
status = '200 OK'
output = 'test fail\n'
try:
assert(env['wsgi.input'].__class__.__name__ == 'mp_request')
assert(env['wsgi.errors'] == sys.stderr)
assert(env['wsgi.version'] == (1,0))
assert(env['wsgi.multithread'] in (True, False))
assert(env['wsgi.multiprocess'] in (True, False))
assert(env['wsgi.url_scheme'] == 'http')
assert(env['SCRIPT_NAME'] == '')
assert(env['PATH_INFO'] == '/tests.py')
output = 'test ok\n'
except:
pass
env['wsgi.errors'].write('written_from_wsgi_test\n')
env['wsgi.errors'].flush()
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
def base_uri(env, start_response):
status = '200 OK'
output = 'test fail\n'
try:
assert(env['wsgi.input'].__class__.__name__ == 'mp_request')
assert(env['wsgi.errors'] == sys.stderr)
assert(env['wsgi.version'] == (1,0))
assert(env['wsgi.multithread'] in (True, False))
assert(env['wsgi.multiprocess'] in (True, False))
assert(env['wsgi.url_scheme'] == 'http')
assert(env['SCRIPT_NAME'] == '/foo')
assert(env['PATH_INFO'] == '/bar')
output = 'test ok\n'
except:
pass
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]