MCPcopy
hub / github.com/benoitc/gunicorn / app

Function app

tests/docker/dirty_ttin_ttou/app.py:40–75  ·  view source on GitHub ↗

Simple WSGI app for testing.

(environ, start_response)

Source from the content-addressed store, hash-verified

38
39
40def app(environ, start_response):
41 """Simple WSGI app for testing."""
42 path = environ.get('PATH_INFO', '/')
43
44 if path == '/health':
45 start_response('200 OK', [('Content-Type', 'text/plain')])
46 return [b'OK']
47
48 # client.execute(app_path, action, *args, **kwargs) — action is the
49 # method name on the DirtyApp. The original fixture passed the data
50 # dict where ``action`` belongs, which surfaced as a 500 from
51 # ``getattr(self, action)`` on the dirty worker.
52 if path == '/unlimited':
53 try:
54 client = get_dirty_client()
55 result = client.execute('app:UnlimitedTask', 'process', {'test': 'data'})
56 start_response('200 OK', [('Content-Type', 'application/json')])
57 return [json.dumps(result).encode()]
58 except Exception as e:
59 start_response('500 Internal Server Error',
60 [('Content-Type', 'text/plain')])
61 return [str(e).encode()]
62
63 if path == '/limited':
64 try:
65 client = get_dirty_client()
66 result = client.execute('app:LimitedTask', 'process', {'test': 'data'})
67 start_response('200 OK', [('Content-Type', 'application/json')])
68 return [json.dumps(result).encode()]
69 except Exception as e:
70 start_response('500 Internal Server Error',
71 [('Content-Type', 'text/plain')])
72 return [str(e).encode()]
73
74 start_response('404 Not Found', [('Content-Type', 'text/plain')])
75 return [b'Not Found']

Callers

nothing calls this directly

Calls 4

get_dirty_clientFunction · 0.90
encodeMethod · 0.80
getMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected