forked from j2labs/brubeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsgi.py
36 lines (26 loc) · 1.02 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from brubeck.request import Request
from brubeck.request_handling import coro_spawn, route_message
def receive_wsgi_req(environ, start_response):
request = Request.parse_wsgi_request(environ)
coro_spawn(route_message, self, request)
class WSGIConnection(object):
"""This class defines request handling methods for wsgi implimentations."""
def __init__(self):
pass
def recv(self):
"""Receives the request from the wsgi server."""
pass
if __name__ == "__main__":
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server
def simple_app(environ, start_response):
setup_testing_defaults(environ)
status = '200 OK'
headers = [('Content-type', 'text/plain')]
start_response(status, headers)
ret = ["%s: %s\n" % (key, value)
for key, value in environ.iteritems()]
return ret
httpd = make_server('', 8000, receive_wsgi_req)
print "Serving on port 8000..."
httpd.serve_forever()