Created
August 22, 2014 01:18
-
-
Save GreenFaith/a0b59fe931739ec4d3c5 to your computer and use it in GitHub Desktop.
wsgi app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simple_app(environ, start_response): | |
"""Simplest possible application object""" | |
status = '200 OK' | |
response_headers = [('Content-type', 'text/plain')] | |
start_response(status, response_headers) | |
return ['Hello world!\n'] | |
class AppClass: | |
"""Produce the same output, but using a class | |
(Note: 'AppClass' is the "application" here, so calling it | |
returns an instance of 'AppClass', which is then the iterable | |
return value of the "application callable" as required by | |
the spec. | |
If we wanted to use *instances* of 'AppClass' as application | |
objects instead, we would have to implement a '__call__' | |
method, which would be invoked to execute the application, | |
and we would need to create an instance for use by the | |
server or gateway. | |
""" | |
def __init__(self, environ, start_response): | |
self.environ = environ | |
self.start = start_response | |
def __iter__(self): | |
status = '200 OK' | |
response_headers = [('Content-type', 'text/plain')] | |
self.start(status, response_headers) | |
yield "Hello world!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment