Show More
@@ -1,34 +1,54 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Implementation of :class:`EchoApp`. |
|
2 | Implementation of :class:`EchoApp`. | |
3 |
|
3 | |||
4 | This WSGI application will just echo back the data which it recieves. |
|
4 | This WSGI application will just echo back the data which it recieves. | |
5 | """ |
|
5 | """ | |
6 |
|
6 | |||
7 | import logging |
|
7 | import logging | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | log = logging.getLogger(__name__) |
|
10 | log = logging.getLogger(__name__) | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | class EchoApp(object): |
|
13 | class EchoApp(object): | |
14 |
|
14 | |||
15 | def __init__(self, repo_path, repo_name, config): |
|
15 | def __init__(self, repo_path, repo_name, config): | |
16 | self._repo_path = repo_path |
|
16 | self._repo_path = repo_path | |
17 | log.info("EchoApp initialized for %s", repo_path) |
|
17 | log.info("EchoApp initialized for %s", repo_path) | |
18 |
|
18 | |||
19 | def __call__(self, environ, start_response): |
|
19 | def __call__(self, environ, start_response): | |
20 | log.debug("EchoApp called for %s", self._repo_path) |
|
20 | log.debug("EchoApp called for %s", self._repo_path) | |
21 | log.debug("Content-Length: %s", environ.get('CONTENT_LENGTH')) |
|
21 | log.debug("Content-Length: %s", environ.get('CONTENT_LENGTH')) | |
22 | environ['wsgi.input'].read() |
|
22 | environ['wsgi.input'].read() | |
23 | status = '200 OK' |
|
23 | status = '200 OK' | |
24 | headers = [('Content-Type', 'text/plain')] |
|
24 | headers = [('Content-Type', 'text/plain')] | |
25 | start_response(status, headers) |
|
25 | start_response(status, headers) | |
26 | return ["ECHO"] |
|
26 | return ["ECHO"] | |
27 |
|
27 | |||
28 |
|
28 | |||
|
29 | class EchoAppStream(object): | |||
|
30 | ||||
|
31 | def __init__(self, repo_path, repo_name, config): | |||
|
32 | self._repo_path = repo_path | |||
|
33 | log.info("EchoApp initialized for %s", repo_path) | |||
|
34 | ||||
|
35 | def __call__(self, environ, start_response): | |||
|
36 | log.debug("EchoApp called for %s", self._repo_path) | |||
|
37 | log.debug("Content-Length: %s", environ.get('CONTENT_LENGTH')) | |||
|
38 | environ['wsgi.input'].read() | |||
|
39 | status = '200 OK' | |||
|
40 | headers = [('Content-Type', 'text/plain')] | |||
|
41 | start_response(status, headers) | |||
|
42 | ||||
|
43 | def generator(): | |||
|
44 | for _ in xrange(1000000): | |||
|
45 | yield "ECHO" | |||
|
46 | return generator() | |||
|
47 | ||||
|
48 | ||||
29 | def create_app(): |
|
49 | def create_app(): | |
30 | """ |
|
50 | """ | |
31 | Allows to run this app directly in a WSGI server. |
|
51 | Allows to run this app directly in a WSGI server. | |
32 | """ |
|
52 | """ | |
33 | stub_config = {} |
|
53 | stub_config = {} | |
34 | return EchoApp('stub_path', 'stub_name', stub_config) |
|
54 | return EchoApp('stub_path', 'stub_name', stub_config) |
General Comments 0
You need to be logged in to leave comments.
Login now