comparison Doc/library/simplehttpserver.rst @ 62359:c6845e83086f legacy-trunk

Addressing RDM's review comments on the doc change.
author Senthil Kumaran <orsenthil@gmail.com>
date Wed, 16 Jun 2010 17:37:32 +0000
parents 84fefbf1d6c0
children ba9cf0df21b0
comparison
equal deleted inserted replaced
62354:84fefbf1d6c0 62359:c6845e83086f
80 Then follows a blank line signifying the end of the headers, and then the 80 Then follows a blank line signifying the end of the headers, and then the
81 contents of the file are output. If the file's MIME type starts with 81 contents of the file are output. If the file's MIME type starts with
82 ``text/`` the file is opened in text mode; otherwise binary mode is used. 82 ``text/`` the file is opened in text mode; otherwise binary mode is used.
83 83
84 The :func:`test` function in the :mod:`SimpleHTTPServer` module is an 84 The :func:`test` function in the :mod:`SimpleHTTPServer` module is an
85 example which interfaces the :class:`SimpleHTTPRequestHandler` as a 85 example which creates a server using the
86 Handler to the :mod:`BaseHTTPServer` module. 86 :class:`SimpleHTTPRequestHandler` as the Handler.
87 87
88 .. versionadded:: 2.5 88 .. versionadded:: 2.5
89 The ``'Last-Modified'`` header. 89 The ``'Last-Modified'`` header.
90 90
91 91
92 The :mod:`SimpleHTTPServer` module can be used the following manner in order to 92 The :mod:`SimpleHTTPServer` module can be used the following manner in order to
93 setup a very basic web server serving files relative to the current directory.:: 93 set up a very basic web server serving files relative to the current
94 directory.::
94 95
95 import SimpleHTTPServer 96 import SimpleHTTPServer
96 import SocketServer 97 import SocketServer
97 98
98 PORT = 8000 99 PORT = 8000
102 httpd = SocketServer.TCPServer(("", PORT), Handler) 103 httpd = SocketServer.TCPServer(("", PORT), Handler)
103 104
104 print "serving at port", PORT 105 print "serving at port", PORT
105 httpd.serve_forever() 106 httpd.serve_forever()
106 107
107 It can also be invoked directly using the ``-m`` switch of interpreter a with 108 :mod:`SimpleHTTPServer` module can also be invoked directly using the ``-m``
108 ``port number`` argument.:: 109 switch of interpreter with a ``port number`` argument. Similar to previous
110 example, this serves the files relative to the current directory.::
109 111
110 python -m SimpleHTTPServer 8000 112 python -m SimpleHTTPServer 8000
111 113
112 .. seealso:: 114 .. seealso::
113 115