simplehandler(stdinstdoutstderrenviron [multithread [multiprocess]]creates wsgi handler that is similar to basecgihandlerbut which gives the underlying application direct access to stdinstdoutstderrand environ this is slightly different than basecgihandler that provides extra logic to process certain features correctly ( in basecgihandlerresponse codes are translated into statusheadersall of these handlers have method run(appthat is used to run wsgi application within the handler here is an example of wsgi application running as traditional cgi script#!/usr/bin/env python def my_app(environstart_response)some application start_response(" ok",[('content-type','text/plain')]return ['hello world'from wgiref handlers import cgihandler hand cgihandler(hand run(my_appwsgiref validate the wsgiref validate module has function that wraps wsgi application with validation wrapper to ensure that both it and the server are operating according to the standard validator(appcreates new wsgi application that wraps the wsgi application app the new application transparently works in the same way as app except that extensive error-checking is added to make sure the application and the server are following the wsgi standard any violation results in an assertionerror exception here is an example of using the validatordef 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 from wsgiref validate import validator serv make_server('', validator(my_app)serv serve_forever(note the material in this section is primarily aimed at users of wsgi who want to create application objects ifon the other handyou are implementing yet another web framework for pythonyou should consult pep for official details on precisely what is needed to make your framework support wsgi if you are using third-party web frameworkyou will need to consult the framework documentation for details concerning its support for wsgi objects given that wsgi is an officially blessed specification with reference implementation in the standard libraryit is increasingly common for frameworks to provide some level of support for it lib fl ff