summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-06-16 16:17:33 +0000
committerSenthil Kumaran <orsenthil@gmail.com>2010-06-16 16:17:33 +0000
commit13d4fafdae869934b740821b07de499de6b94cc3 (patch)
treee2a9c16cdeb9ca59edc0f9772aa1aab49c83cd8a
parentea568854b079506c302725ac24529c60b61cc896 (diff)
downloadcpython-git-13d4fafdae869934b740821b07de499de6b94cc3.tar.gz
Merged revisions 82018 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r82018 | senthil.kumaran | 2010-06-16 20:25:31 +0530 (Wed, 16 Jun 2010) | 3 lines Fix Issue8937 - SimpleHTTPServer should contain usage example ........
-rw-r--r--Doc/library/simplehttpserver.rst24
1 files changed, 23 insertions, 1 deletions
diff --git a/Doc/library/simplehttpserver.rst b/Doc/library/simplehttpserver.rst
index bdf66d1cbb..79e01d0ea5 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`