blob: 75d408950e69ef43244c935e3b84d1ee0d5d429c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import atexit
class application:
def __init__(self, environ, start_response):
self.environ = environ
self.start = start_response
def __iter__(self):
atexit.register(self._atexit)
content_length = int(self.environ.get('CONTENT_LENGTH', 0))
body = bytes(self.environ['wsgi.input'].read(content_length))
self.start(
'200',
[
('Content-Length', str(len(body))),
],
)
yield body
def _atexit(self):
self.start('200', [('Content-Length', '0')])
|