diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-06-16 14:55:31 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-06-16 14:55:31 (GMT) |
commit | e55a20525e6c32c7d1361e9a61f51c96c366d2ce (patch) | |
tree | df65d25be98c8f28ec94bb8625a322162a8aab68 /Doc | |
parent | 526e5eed713d792468bc6912b6b555fe4509a1f1 (diff) | |
download | cpython-e55a20525e6c32c7d1361e9a61f51c96c366d2ce.zip cpython-e55a20525e6c32c7d1361e9a61f51c96c366d2ce.tar.gz cpython-e55a20525e6c32c7d1361e9a61f51c96c366d2ce.tar.bz2 |
Fix Issue8937 - SimpleHTTPServer should contain usage example
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/simplehttpserver.rst | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Doc/library/simplehttpserver.rst b/Doc/library/simplehttpserver.rst index bdf66d1..79e01d0 100644 --- a/Doc/library/simplehttpserver.rst +++ b/Doc/library/simplehttpserver.rst @@ -81,12 +81,34 @@ The :mod:`SimpleHTTPServer` module defines the following class: contents of the file are output. If the file's MIME type starts with ``text/`` the file is opened in text mode; otherwise binary mode is used. - For example usage, see the implementation of the :func:`test` function. + The :func:`test` function in the :mod:`SimpleHTTPServer` module is an + example which interfaces the :class:`SimpleHTTPRequestHandler` as a + Handler to the :mod:`BaseHTTPServer` module. .. versionadded:: 2.5 The ``'Last-Modified'`` header. +The :mod:`SimpleHTTPServer` module can be used the following manner in order to +setup a very basic web server serving files relative to the current directory.:: + + import SimpleHTTPServer + import SocketServer + + PORT = 8000 + + Handler = SimpleHTTPServer.SimpleHTTPRequestHandler + + httpd = SocketServer.TCPServer(("", PORT), Handler) + + print "serving at port", PORT + httpd.serve_forever() + +It can also be invoked directly using the ``-m`` switch of interpreter a with +``port number`` argument.:: + + python -m SimpleHTTPServer 8000 + .. seealso:: Module :mod:`BaseHTTPServer` |