diff options
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r-- | libpathod/pathod.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index c700b550..c8608bd6 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -1,4 +1,6 @@ -from netlib import tcp, protocol, odict +from netlib import tcp, protocol, odict, wsgi +import version, app + class PathodHandler(tcp.BaseHandler): def handle(self): @@ -13,13 +15,24 @@ class PathodHandler(tcp.BaseHandler): content = protocol.read_http_body_request( self.rfile, self.wfile, headers, httpversion, None ) - print method, path, httpversion - #return flow.Request(client_conn, httpversion, host, port, "http", method, path, headers, content) + cc = wsgi.ClientConn(self.client_address) + req = wsgi.Request(cc, "http", method, path, headers, content) + sn = self.connection.getsockname() + app = wsgi.WSGIAdaptor( + self.server.app, + sn[0], + self.server.port, + version.NAMEVERSION + ) + app.serve(req, self.wfile) + class Pathod(tcp.TCPServer): def __init__(self, addr): tcp.TCPServer.__init__(self, addr) + self.app = app.app + self.app.config["pathod"] = self def handle_connection(self, request, client_address): PathodHandler(request, client_address, self) |