Changeset 391 for python/trunk/Doc/library/simplehttpserver.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/simplehttpserver.rst
r2 r391 9 9 .. note:: 10 10 The :mod:`SimpleHTTPServer` module has been merged into :mod:`http.server` in 11 Python 3. 0.The :term:`2to3` tool will automatically adapt imports when12 converting your sources to 3.0.11 Python 3. The :term:`2to3` tool will automatically adapt imports when 12 converting your sources to Python 3. 13 13 14 14 … … 82 82 ``text/`` the file is opened in text mode; otherwise binary mode is used. 83 83 84 For example usage, see the implementation of the :func:`test` function. 84 The :func:`test` function in the :mod:`SimpleHTTPServer` module is an 85 example which creates a server using the :class:`SimpleHTTPRequestHandler` 86 as the Handler. 85 87 86 88 .. versionadded:: 2.5 87 89 The ``'Last-Modified'`` header. 88 90 91 92 The :mod:`SimpleHTTPServer` module can be used in the following manner in order 93 to set up a very basic web server serving files relative to the current 94 directory. :: 95 96 import SimpleHTTPServer 97 import SocketServer 98 99 PORT = 8000 100 101 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler 102 103 httpd = SocketServer.TCPServer(("", PORT), Handler) 104 105 print "serving at port", PORT 106 httpd.serve_forever() 107 108 The :mod:`SimpleHTTPServer` module can also be invoked directly using the 109 :option:`-m` switch of the interpreter with a ``port number`` argument. 110 Similar to the previous example, this serves the files relative to the 111 current directory. :: 112 113 python -m SimpleHTTPServer 8000 89 114 90 115 .. seealso::
Note:
See TracChangeset
for help on using the changeset viewer.