Back to index

python3.2  3.2.2
Classes | Functions | Variables
wsgiref.simple_server Namespace Reference


class  ServerHandler
class  WSGIServer
class  WSGIRequestHandler


def demo_app
def make_server


string __version__ = "0.2"
list __all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']
string server_version = "WSGIServer/"
string sys_version = "Python/"
string software_version = ' '
tuple httpd = make_server('', 8000, demo_app)
tuple sa = httpd.socket.getsockname()

Detailed Description

BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.

Function Documentation

def wsgiref.simple_server.demo_app (   environ,

Definition at line 129 of file

00130 def demo_app(environ,start_response):
00131     from io import StringIO
00132     stdout = StringIO()
00133     print("Hello world!", file=stdout)
00134     print(file=stdout)
00135     h = sorted(environ.items())
00136     for k,v in h:
00137         print(k,'=',repr(v), file=stdout)
00138     start_response("200 OK", [('Content-Type','text/plain; charset=utf-8')])
00139     return [stdout.getvalue().encode("utf-8")]

Here is the call graph for this function:

def wsgiref.simple_server.make_server (   host,
  server_class = WSGIServer,
  handler_class = WSGIRequestHandler 
Create a new WSGI server listening on `host` and `port` for `app`

Definition at line 143 of file

00144 ):
00145     """Create a new WSGI server listening on `host` and `port` for `app`"""
00146     server = server_class((host, port), handler_class)
00147     server.set_app(app)
00148     return server

Here is the caller graph for this function:

Variable Documentation

Definition at line 19 of file

Definition at line 18 of file

Definition at line 151 of file

tuple = httpd.socket.getsockname()

Definition at line 152 of file

Definition at line 22 of file

Definition at line 24 of file

Definition at line 23 of file