[Python-checkins] r82022 - in python/branches/py3k: Doc/library/http.server.rst

senthil.kumaran python-checkins at python.org
Wed Jun 16 18:41:11 CEST 2010


Author: senthil.kumaran
Date: Wed Jun 16 18:41:11 2010
New Revision: 82022

Log:
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
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/library/http.server.rst

Modified: python/branches/py3k/Doc/library/http.server.rst
==============================================================================
--- python/branches/py3k/Doc/library/http.server.rst	(original)
+++ python/branches/py3k/Doc/library/http.server.rst	Wed Jun 16 18:41:11 2010
@@ -281,8 +281,30 @@
       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.
+      For example usage, see the implementation of the :func:`test` function
+      invocation in the :mod:`http.server` module.
 
+The :class:`SimpleHTTPRequestHandler` class can be invoked the following manner
+with the :mod:`http.server` to create a very basic webserver serving files
+relative to the current directory.::
+
+        import http.server
+        import socketserver
+
+        PORT = 8000
+
+        Handler = http.server.SimpleHTTPRequestHandler
+
+        httpd = socketserver.TCPServer(("", PORT), Handler)
+
+        print("serving at port", PORT)
+        httpd.serve_forever()
+
+:mod:`http.server` can also be invoked directly using the ``-m`` switch of
+interpreter a with ``port number`` argument which interfaces
+:class:`SimpleHTTPRequestHandler` by default.::
+
+        python -m http.server 8000
 
 .. class:: CGIHTTPRequestHandler(request, client_address, server)
 


More information about the Python-checkins mailing list