File: wsgitest.py

package info (click to toggle)
libapache2-mod-python 3.5.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,864 kB
  • sloc: python: 7,471; ansic: 7,025; makefile: 296; lex: 246; sh: 212
file content (53 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (3)
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
53

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]