Pyjo.Server.CGI - CGI server

import Pyjo.Server.CGI
from Pyjo.Util import b

cgi = Pyjo.Server.CGI.new()
cgi.unsubscribe('request')

@cgi.on
def request(cgi, 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()

cgi.run()

Pyjo.Server.CGI is a simple and portable implementation of RFC 3875.

Events

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

Classes

class Pyjo.Server.CGI.Pyjo_Server_CGI(**kwargs)

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

nph = False
boolean = cgi.nph
cgi.nph = boolean

Activate non-parsed header mode.

run()
status = cgi.run()

Run CGI.

Pyjo.Server.CGI.object

alias of Pyjo_Server_CGI