Mercurial > cpython-lru_cache-weakref
diff Doc/library/basehttpserver.rst @ 52903:3889d9528601 2.6
Merged revisions 71058,71149-71150,71212,71214-71216,71222,71225,71234,71237-71238,71240-71241,71243,71249,71251 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r71058 | georg.brandl | 2009-04-02 20:09:04 +0200 (Do, 02 Apr 2009) | 3 lines
PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject
call on hitting the recursion limit into just assigning it to the arguments provided.
........
r71149 | georg.brandl | 2009-04-04 15:42:39 +0200 (Sa, 04 Apr 2009) | 1 line
#5642: clarify map() compatibility to the builtin.
........
r71150 | georg.brandl | 2009-04-04 15:45:49 +0200 (Sa, 04 Apr 2009) | 1 line
#5601: clarify that webbrowser is not meant for file names.
........
r71212 | georg.brandl | 2009-04-05 12:24:20 +0200 (So, 05 Apr 2009) | 1 line
#1742837: expand HTTP server docs, and fix SocketServer ones to document methods as methods, not functions.
........
r71214 | georg.brandl | 2009-04-05 12:29:57 +0200 (So, 05 Apr 2009) | 1 line
Normalize spelling of Mac OS X.
........
r71215 | georg.brandl | 2009-04-05 12:32:26 +0200 (So, 05 Apr 2009) | 1 line
Avoid sure signs of a diseased mind.
........
r71216 | georg.brandl | 2009-04-05 12:41:02 +0200 (So, 05 Apr 2009) | 1 line
#1718017: document the relation of os.path and the posixpath, ntpath etc. modules better.
........
r71222 | georg.brandl | 2009-04-05 13:07:14 +0200 (So, 05 Apr 2009) | 1 line
#5615: make it possible to configure --without-threads again.
........
r71225 | georg.brandl | 2009-04-05 13:54:07 +0200 (So, 05 Apr 2009) | 1 line
#5580: no need to use parentheses when converterr() argument is actually a type description.
........
r71234 | georg.brandl | 2009-04-05 15:16:35 +0200 (So, 05 Apr 2009) | 1 line
Whitespace normalization.
........
r71237 | georg.brandl | 2009-04-05 16:24:52 +0200 (So, 05 Apr 2009) | 1 line
#1326077: fix traceback formatting of SyntaxErrors. This fixes two differences with formatting coming from Python: a) the reproduction of location details in the error message if no line text is given, b) the prefixing of the last line by one space.
........
r71238 | georg.brandl | 2009-04-05 16:25:41 +0200 (So, 05 Apr 2009) | 1 line
Add NEWS entry for r71237.
........
r71240 | georg.brandl | 2009-04-05 16:40:06 +0200 (So, 05 Apr 2009) | 1 line
#5370: doc update about unpickling objects with custom __getattr__ etc. methods.
........
r71241 | georg.brandl | 2009-04-05 16:48:49 +0200 (So, 05 Apr 2009) | 1 line
#5471: fix expanduser() for $HOME set to "/".
........
r71243 | georg.brandl | 2009-04-05 17:14:29 +0200 (So, 05 Apr 2009) | 1 line
#5432: make plistlib docstring a raw string, since it contains examples with backslash escapes.
........
r71249 | georg.brandl | 2009-04-05 18:30:43 +0200 (So, 05 Apr 2009) | 1 line
#5444: adapt make.bat to new htmlhelp output file name.
........
r71251 | georg.brandl | 2009-04-05 19:17:42 +0200 (So, 05 Apr 2009) | 1 line
#5298: clarify docs about GIL by using more consistent wording.
........
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 05 Apr 2009 21:26:31 +0000 |
| parents | 30834b9aa193 |
| children | b5674229d0f9 |
line wrap: on
line diff
--- a/Doc/library/basehttpserver.rst Sun Apr 05 21:23:27 2009 +0000 +++ b/Doc/library/basehttpserver.rst Sun Apr 05 21:26:31 2009 +0000 @@ -15,8 +15,6 @@ pair: HTTP; protocol single: URL single: httpd - -.. index:: module: SimpleHTTPServer module: CGIHTTPServer @@ -26,7 +24,8 @@ :mod:`CGIHTTPServer` modules. The first class, :class:`HTTPServer`, is a :class:`SocketServer.TCPServer` -subclass. It creates and listens at the HTTP socket, dispatching the requests +subclass, and therefore implements the :class:`SocketServer.BaseServer` +interface. It creates and listens at the HTTP socket, dispatching the requests to a handler. Code to create and run the server looks like this:: def run(server_class=BaseHTTPServer.HTTPServer, @@ -269,12 +268,31 @@ performed on the client's IP address. +More examples +------------- + +To create a server that doesn't run forever, but until some condition is +fulfilled:: + + def run_while_true(server_class=BaseHTTPServer.HTTPServer, + handler_class=BaseHTTPServer.BaseHTTPRequestHandler): + """ + This assumes that keep_running() is a function of no arguments which + is tested initially and after each request. If its return value + is true, the server continues. + """ + server_address = ('', 8000) + httpd = server_class(server_address, handler_class) + while keep_running(): + httpd.handle_request() + + .. seealso:: Module :mod:`CGIHTTPServer` Extended request handler that supports CGI scripts. Module :mod:`SimpleHTTPServer` - Basic request handler that limits response to files actually under the document - root. + Basic request handler that limits response to files actually under the + document root.
