a | b | |
---|
0 | 0 | | def my_awesome_application(environ): |
---|
1 | 1 | | # do stuff |
---|
... | |
---|
2 | | - | yield b'200 OK', [], ["Hello, World!"] |
---|
| 2 | + | return b'200 OK', [], ["Hello, World!"] |
---|
... | |
---|
3 | 3 | | |
---|
4 | 4 | | def my_middelware(app): |
---|
5 | 5 | | def wrapper(environ): |
---|
6 | 6 | | # maybe edit environ |
---|
7 | 7 | | try: |
---|
... | |
---|
8 | | - | status, headers, body = yield app(environ) |
---|
| 8 | + | status, headers, body = app(environ) |
---|
... | |
---|
9 | 9 | | # maybe edit response: |
---|
10 | 10 | | # body = (piglatin(data) for data in body) |
---|
11 | 11 | | return status, headers, body |
---|
... | |
---|
16 | 16 | | |
---|
17 | 17 | | def my_server(app, httpreq): |
---|
18 | 18 | | environ = wsgi.make_environ(httpreq) |
---|
... | |
---|
19 | | - | |
---|
19 | | - | def process_response(result): |
---|
19 | | - | status, headers, body = result |
---|
| 19 | + | try: |
---|
| 19 | + | status, headers, body = app(environ) |
---|
... | |
---|
22 | 22 | | write_headers(httpreq, status, headers) |
---|
... | |
---|
23 | | - | Coroutine(body, body_trampoline, finish_response) |
---|
23 | | - | |
---|
23 | | - | def finish_response(result): |
---|
23 | | - | # cleanup, if any |
---|
23 | | - | |
---|
23 | | - | Coroutine(app(environ), app_trampoline, process_response) |
---|
| 23 | + | for data in body: |
---|
| 23 | + | write_data(httpreq, data) |
---|
| 23 | + | except: |
---|
| 23 | + | respond_with_500() |
---|
... | |
---|