Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{BaseHTTPServer} --- |
| 2 | Basic HTTP server.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | \declaremodule{standard}{BaseHTTPServer} |
| 4 | |
Fred Drake | 72d157e | 1998-08-06 21:23:17 +0000 | [diff] [blame] | 5 | \modulesynopsis{Basic HTTP server (base class for |
| 6 | \class{SimpleHTTPServer} and \class{CGIHTTPServer}).} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 8 | |
| 9 | \indexii{WWW}{server} |
| 10 | \indexii{HTTP}{protocol} |
| 11 | \index{URL} |
| 12 | \index{httpd} |
| 13 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 14 | |
| 15 | This module defines two classes for implementing HTTP servers |
| 16 | (web servers). Usually, this module isn't used directly, but is used |
| 17 | as a basis for building functioning web servers. See the |
Fred Drake | c46864e | 1999-06-14 19:49:50 +0000 | [diff] [blame] | 18 | \module{SimpleHTTPServer}\refstmodindex{SimpleHTTPServer} and |
| 19 | \refmodule{CGIHTTPServer}\refstmodindex{CGIHTTPServer} modules. |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 20 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 21 | The first class, \class{HTTPServer}, is a |
| 22 | \class{SocketServer.TCPServer} subclass. It creates and listens at the |
| 23 | web socket, dispatching the requests to a handler. Code to create and |
| 24 | run the server looks like this: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 25 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 26 | \begin{verbatim} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 27 | def run(server_class=BaseHTTPServer.HTTPServer, |
| 28 | handler_class=BaseHTTPServer.BaseHTTPRequestHandler): |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 29 | server_address = ('', 8000) |
| 30 | httpd = server_class(server_address, handler_class) |
| 31 | httpd.serve_forever() |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 32 | \end{verbatim} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 33 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 34 | \begin{classdesc}{HTTPServer}{server_address, RequestHandlerClass} |
| 35 | This class builds on the \class{TCPServer} class by |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 36 | storing the server address as instance |
| 37 | variables named \member{server_name} and \member{server_port}. The |
| 38 | server is accessible by the handler, typically through the handler's |
| 39 | \member{server} instance variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 40 | \end{classdesc} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 41 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 42 | \begin{classdesc}{BaseHTTPRequestHandler}{request, client_address, server} |
| 43 | This class is used |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 44 | to handle the HTTP requests that arrive at the server. By itself, |
| 45 | it cannot respond to any actual HTTP requests; it must be subclassed |
| 46 | to handle each request method (e.g. GET or POST). |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 47 | \class{BaseHTTPRequestHandler} provides a number of class and instance |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 48 | variables, and methods for use by subclasses. |
| 49 | |
| 50 | The handler will parse the request and the headers, then call a |
| 51 | method specific to the request type. The method name is constructed |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 52 | from the request. For example, for the request method \samp{SPAM}, the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 53 | \method{do_SPAM()} method will be called with no arguments. All of |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 54 | the relevant information is stored in instance variables of the |
| 55 | handler. Subclasses should not need to override or extend the |
| 56 | \method{__init__()} method. |
| 57 | \end{classdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 58 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 59 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 60 | \class{BaseHTTPRequestHandler} has the following instance variables: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 61 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 62 | \begin{memberdesc}{client_address} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 63 | Contains a tuple of the form \code{(\var{host}, \var{port})} referring |
| 64 | to the client's address. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 65 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 66 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 67 | \begin{memberdesc}{command} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 68 | Contains the command (request type). For example, \code{'GET'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 69 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 70 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 71 | \begin{memberdesc}{path} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 72 | Contains the request path. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 73 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 74 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 75 | \begin{memberdesc}{request_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 76 | Contains the version string from the request. For example, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 77 | \code{'HTTP/1.0'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 78 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 79 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 80 | \begin{memberdesc}{headers} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 81 | Holds an instance of the class specified by the \member{MessageClass} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 82 | class variable. This instance parses and manages the headers in |
| 83 | the HTTP request. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 84 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 85 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 86 | \begin{memberdesc}{rfile} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 87 | Contains an input stream, positioned at the start of the optional |
| 88 | input data. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 89 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 90 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 91 | \begin{memberdesc}{wfile} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 92 | Contains the output stream for writing a response back to the client. |
| 93 | Proper adherance to the HTTP protocol must be used when writing |
| 94 | to this stream. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 95 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 96 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 97 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 98 | \class{BaseHTTPRequestHandler} has the following class variables: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 99 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 100 | \begin{memberdesc}{server_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 101 | Specifies the server software version. You may want to override |
| 102 | this. |
| 103 | The format is multiple whitespace-separated strings, |
| 104 | where each string is of the form name[/version]. |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 105 | For example, \code{'BaseHTTP/0.2'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 106 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 107 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 108 | \begin{memberdesc}{sys_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 109 | Contains the Python system version, in a form usable by the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 110 | \member{version_string} method and the \member{server_version} class |
| 111 | variable. For example, \code{'Python/1.4'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 112 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 113 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 114 | \begin{memberdesc}{error_message_format} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 115 | Specifies a format string for building an error response to the |
| 116 | client. It uses parenthesized, keyed format specifiers, so the |
| 117 | format operand must be a dictionary. The \var{code} key should |
| 118 | be an integer, specifing the numeric HTTP error code value. |
| 119 | \var{message} should be a string containing a (detailed) error |
| 120 | message of what occurred, and \var{explain} should be an |
| 121 | explanation of the error code number. Default \var{message} |
| 122 | and \var{explain} values can found in the \var{responses} |
| 123 | class variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 124 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 125 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 126 | \begin{memberdesc}{protocol_version} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 127 | This specifies the HTTP protocol version used in responses. |
| 128 | Typically, this should not be overridden. Defaults to |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 129 | \code{'HTTP/1.0'}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 130 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 131 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 132 | \begin{memberdesc}{MessageClass} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 133 | Specifies a \class{rfc822.Message}-like class to parse HTTP |
| 134 | headers. Typically, this is not overridden, and it defaults to |
| 135 | \class{mimetools.Message}. |
| 136 | \withsubitem{(in module mimetools)}{\ttindex{Message}} |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 137 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 138 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 139 | \begin{memberdesc}{responses} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 140 | This variable contains a mapping of error code integers to two-element |
| 141 | tuples containing a short and long message. For example, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 142 | \code{\{\var{code}: (\var{shortmessage}, \var{longmessage})\}}. The |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 143 | \var{shortmessage} is usually used as the \var{message} key in an |
| 144 | error response, and \var{longmessage} as the \var{explain} key |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 145 | (see the \member{error_message_format} class variable). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 146 | \end{memberdesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 147 | |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 148 | |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 149 | A \class{BaseHTTPRequestHandler} instance has the following methods: |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 150 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 151 | \begin{methoddesc}{handle}{} |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 152 | Overrides the superclass' \method{handle()} method to provide the |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 153 | specific handler behavior. This method will parse and dispatch |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 154 | the request to the appropriate \method{do_*()} method. |
| 155 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 156 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 157 | \begin{methoddesc}{send_error}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 158 | Sends and logs a complete error reply to the client. The numeric |
| 159 | \var{code} specifies the HTTP error code, with \var{message} as |
| 160 | optional, more specific text. A complete set of headers is sent, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 161 | followed by text composed using the \member{error_message_format} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 162 | class variable. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 163 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 164 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 165 | \begin{methoddesc}{send_response}{code\optional{, message}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 166 | Sends a response header and logs the accepted request. The HTTP |
| 167 | response line is sent, followed by \emph{Server} and \emph{Date} |
| 168 | headers. The values for these two headers are picked up from the |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 169 | \method{version_string()} and \method{date_time_string()} methods, |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 170 | respectively. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 171 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 172 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 173 | \begin{methoddesc}{send_header}{keyword, value} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 174 | Writes a specific MIME header to the output stream. \var{keyword} |
| 175 | should specify the header keyword, with \var{value} specifying |
| 176 | its value. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 177 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 178 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 179 | \begin{methoddesc}{end_headers}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 180 | Sends a blank line, indicating the end of the MIME headers in |
| 181 | the response. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 182 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 183 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 184 | \begin{methoddesc}{log_request}{\optional{code\optional{, size}}} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 185 | Logs an accepted (successful) request. \var{code} should specify |
| 186 | the numeric HTTP code associated with the response. If a size of |
| 187 | the response is available, then it should be passed as the |
| 188 | \var{size} parameter. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 189 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 190 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 191 | \begin{methoddesc}{log_error}{...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 192 | Logs an error when a request cannot be fulfilled. By default, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 193 | it passes the message to \method{log_message()}, so it takes the |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 194 | same arguments (\var{format} and additional values). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 195 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 196 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 197 | \begin{methoddesc}{log_message}{format, ...} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 198 | Logs an arbitrary message to \code{sys.stderr}. This is typically |
| 199 | overridden to create custom error logging mechanisms. The |
| 200 | \var{format} argument is a standard printf-style format string, |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 201 | where the additional arguments to \method{log_message()} are applied |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 202 | as inputs to the formatting. The client address and current date |
| 203 | and time are prefixed to every message logged. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 204 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 205 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 206 | \begin{methoddesc}{version_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 207 | Returns the server software's version string. This is a combination |
Fred Drake | f9e1f65 | 1998-03-14 07:00:41 +0000 | [diff] [blame] | 208 | of the \member{server_version} and \member{sys_version} class variables. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 209 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 210 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 211 | \begin{methoddesc}{date_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 212 | Returns the current date and time, formatted for a message header. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 213 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 214 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 215 | \begin{methoddesc}{log_data_time_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 216 | Returns the current date and time, formatted for logging. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 217 | \end{methoddesc} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 218 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 219 | \begin{methoddesc}{address_string}{} |
Guido van Rossum | 9cb6480 | 1997-12-29 20:01:55 +0000 | [diff] [blame] | 220 | Returns the client address, formatted for logging. A name lookup |
| 221 | is performed on the client's IP address. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 222 | \end{methoddesc} |
Fred Drake | c46864e | 1999-06-14 19:49:50 +0000 | [diff] [blame] | 223 | |
| 224 | |
| 225 | \begin{seealso} |
| 226 | \seemodule{CGIHTTPServer}{Extended request handler that supports CGI |
| 227 | scripts.} |
| 228 | |
| 229 | \seemodule{SimpleHTTPServer}{Basic request handler that limits response |
| 230 | to files actually under the document root.} |
| 231 | \end{seealso} |