wsgiref.simple_server (version 0.1)
index
/usr/local/lib/python2.5/wsgiref/simple_server.py
Module Docs

BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)
 
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.

 
Modules
       
sys
urllib

 
Classes
       
BaseHTTPServer.BaseHTTPRequestHandler(SocketServer.StreamRequestHandler)
WSGIRequestHandler
BaseHTTPServer.HTTPServer(SocketServer.TCPServer)
WSGIServer

 
class WSGIRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler)
    
Method resolution order:
WSGIRequestHandler
BaseHTTPServer.BaseHTTPRequestHandler
SocketServer.StreamRequestHandler
SocketServer.BaseRequestHandler

Methods defined here:
get_environ(self)
get_stderr(self)
handle(self)
Handle a single HTTP request

Data and other attributes defined here:
server_version = 'WSGIServer/0.1'

Methods inherited from BaseHTTPServer.BaseHTTPRequestHandler:
address_string(self)
Return the client address formatted for logging.
 
This version looks up the full hostname using gethostbyaddr(),
and tries to find a name that contains at least one dot.
date_time_string(self, timestamp=None)
Return the current date and time formatted for a message header.
end_headers(self)
Send the blank line ending the MIME headers.
handle_one_request(self)
Handle a single HTTP request.
 
You normally don't need to override this method; see the class
__doc__ string for information on how to handle specific HTTP
commands such as GET and POST.
log_date_time_string(self)
Return the current time formatted for logging.
log_error(self, *args)
Log an error.
 
This is called when a request cannot be fulfilled.  By
default it passes the message on to log_message().
 
Arguments are the same as for log_message().
 
XXX This should go to the separate error log.
log_message(self, format, *args)
Log an arbitrary message.
 
This is used by all other logging functions.  Override
it if you have specific logging wishes.
 
The first argument, FORMAT, is a format string for the
message to be logged.  If the format string contains
any % escapes requiring parameters, they should be
specified as subsequent arguments (it's just like
printf!).
 
The client host and current date/time are prefixed to
every message.
log_request(self, code='-', size='-')
Log an accepted request.
 
This is called by send_response().
parse_request(self)
Parse a request (internal).
 
The request should be stored in self.raw_requestline; the results
are in self.command, self.path, self.request_version and
self.headers.
 
Return True for success, False for failure; on failure, an
error is sent back.
send_error(self, code, message=None)
Send and log an error reply.
 
Arguments are the error code, and a detailed message.
The detailed message defaults to the short entry matching the
response code.
 
This sends an error response (so it must be called before any
output has been generated), logs the error, and finally sends
a piece of HTML explaining the error to the user.
send_header(self, keyword, value)
Send a MIME header.
send_response(self, code, message=None)
Send the response header and log the response code.
 
Also send two standard headers with the server software
version and the current date.
version_string(self)
Return the server software version string.

Data and other attributes inherited from BaseHTTPServer.BaseHTTPRequestHandler:
MessageClass = <class mimetools.Message at 0xb71e871c>
A derived class of rfc822.Message that knows about MIME headers and
contains some hooks for decoding encoded and multipart messages.
error_message_format = '<head>\n<title>Error response</title>\n</head>\n<bo...ode explanation: %(code)s = %(explain)s.\n</body>\n'
monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
protocol_version = 'HTTP/1.0'
responses = {100: ('Continue', 'Request received, please continue'), 101: ('Switching Protocols', 'Switching to new protocol; obey Upgrade header'), 200: ('OK', 'Request fulfilled, document follows'), 201: ('Created', 'Document created, URL follows'), 202: ('Accepted', 'Request accepted, processing continues off-line'), 203: ('Non-Authoritative Information', 'Request fulfilled from cache'), 204: ('No Content', 'Request fulfilled, nothing follows'), 205: ('Reset Content', 'Clear input form for further input.'), 206: ('Partial Content', 'Partial content follows.'), 300: ('Multiple Choices', 'Object has several resources -- see URI list'), ...}
sys_version = 'Python/2.5.1'
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

Methods inherited from SocketServer.StreamRequestHandler:
finish(self)
setup(self)

Data and other attributes inherited from SocketServer.StreamRequestHandler:
rbufsize = -1
wbufsize = 0

Methods inherited from SocketServer.BaseRequestHandler:
__init__(self, request, client_address, server)

 
class WSGIServer(BaseHTTPServer.HTTPServer)
    BaseHTTPServer that implements the Python WSGI protocol
 
 
Method resolution order:
WSGIServer
BaseHTTPServer.HTTPServer
SocketServer.TCPServer
SocketServer.BaseServer

Methods defined here:
get_app(self)
server_bind(self)
Override server_bind to store the server name.
set_app(self, application)
setup_environ(self)

Data and other attributes defined here:
application = None

Data and other attributes inherited from BaseHTTPServer.HTTPServer:
allow_reuse_address = 1

Methods inherited from SocketServer.TCPServer:
__init__(self, server_address, RequestHandlerClass)
Constructor.  May be extended, do not override.
close_request(self, request)
Called to clean up an individual request.
fileno(self)
Return socket file number.
 
Interface required by select().
get_request(self)
Get the request and client address from the socket.
 
May be overridden.
server_activate(self)
Called by constructor to activate the server.
 
May be overridden.
server_close(self)
Called to clean-up the server.
 
May be overridden.

Data and other attributes inherited from SocketServer.TCPServer:
address_family = 2
request_queue_size = 5
socket_type = 1

Methods inherited from SocketServer.BaseServer:
finish_request(self, request, client_address)
Finish one request by instantiating RequestHandlerClass.
handle_error(self, request, client_address)
Handle an error gracefully.  May be overridden.
 
The default is to print a traceback and continue.
handle_request(self)
Handle one request, possibly blocking.
process_request(self, request, client_address)
Call finish_request.
 
Overridden by ForkingMixIn and ThreadingMixIn.
serve_forever(self)
Handle one request at a time until doomsday.
verify_request(self, request, client_address)
Verify the request.  May be overridden.
 
Return True if we should proceed with this request.

 
Functions
       
demo_app(environ, start_response)
make_server(host, port, app, server_class=<class wsgiref.simple_server.WSGIServer at 0xb6171e0c>, handler_class=<class wsgiref.simple_server.WSGIRequestHandler at 0xb6171cec>)
Create a new WSGI server listening on `host` and `port` for `app`

 
Data
        __all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']
__version__ = '0.1'