web programming wsgiref package the wsgiref package provides reference implementation of the wsgi standard that allows applications to be tested in stand-alone servers or executed as normal cgi scripts wsgiref simple_server the wsgiref simple_server module implements simple stand-alone http server that runs single wsgi application there are just two functions of interestmake_server(hostportappcreates an http server that accepts connections on the given host name host and port number port app is function or callable object that implements wsgi application to run the serveruse serve_forever(where is an instance of the server that is returned demo_app(environstart_responsea complete wsgi application that returns page with "hello worldmessage on it this can be used as the app argument to make_server(to verify that the server is working correctly here is an example of running simple wsgi serverdef my_app(environstart_response)some application start_response(" ok",[('content-type','text/plain')]return ['hello world'if _name_ =' _main_ 'from wsgiref simple_server import make_server serv make_server('', my_appserv serve_forever(wsgiref handlers the wsgiref handlers module contains handler objects for setting up wsgi execution environment so that applications can run within another webserver ( cgi scripting under apachethere are few different objects cgihandler(creates wsgi handler object that runs inside standard cgi environment this handler collects information from the standard environment variables and / streams as described in the cgi library module basecgihandler(stdinstdoutstderrenviron [multithread [multiprocess]]creates wsgi handler that operates within cgi environmentbut where the standard / streams and environment variables might be set up in different way stdinstdoutand stderr specify file-like objects for the standard / streams environ is dictionary of environment variables that is expected to already contain the standard cgi environment variables multithread and multiprocess are boolean flags that are used to set the wsgi multithread and wsgi multiprocess environment variables by defaultmultithread is true and multiprocess is false lib fl ff