Pyjo.Server.WSGI - WSGI server

import Pyjo.Server.WSGI
from Pyjo.Util import b

from wsgiref.simple_server import make_server

wsgi = Pyjo.Server.WSGI.new()
wsgi.unsubscribe('request')

@wsgi.on
def request(wsgi, tx):
    # Request
    method = tx.req.method
    path = tx.req.url.path

    # Response
    tx.res.code = 200
    tx.res.headers.content_type = 'text/plain'
    tx.res.body = b("{0} request for {1}!".format(method, path))

    # Resume transaction
    tx.resume()

app = wsgi.to_wsgi_app()

httpd = make_server('', 3000, app)
httpd.serve_forever()

Pyjo.Server.WSGI allows Pyjoyment applications to run on all WSGI compatible servers.

Events

Pyjo.Server.WSGI inherits all events from Pyjo.Server.Base.

Classes

class Pyjo.Server.WSGI.Pyjo_Server_WSGI(**kwargs)

Pyjo.Server.WSGI inherits all attributes and methods from Pyjo.Server.Base and implements the following new ones.

run(environ)
res = psgi.run(environ)

Run WSGI.

Pyjo.Server.WSGI.object

alias of Pyjo_Server_WSGI