diff options
author | Stéphane Wirtel <stephane@wirtel.be> | 2017-05-24 07:29:06 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-05-24 07:29:06 (GMT) |
commit | a17a2f52c4c3b37414da95a152fc8669978c7c83 (patch) | |
tree | abf6327c00ac9ae647474b4b63a704a396ba5a58 /Doc/library | |
parent | 07244a83014fad42da937c17d98474b47a570bf7 (diff) | |
download | cpython-a17a2f52c4c3b37414da95a152fc8669978c7c83.zip cpython-a17a2f52c4c3b37414da95a152fc8669978c7c83.tar.gz cpython-a17a2f52c4c3b37414da95a152fc8669978c7c83.tar.bz2 |
bpo-28707: Add the directory parameter to http.server.SimpleHTTPRequestHandler and http.server module (#1776)
* bpo-28707: call the constructor of SimpleHTTPRequestHandler in the test with a mock object
* bpo-28707: Add the directory parameter to http.server.SimpleHTTPRequestHandler and http.server module
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/http.server.rst | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index ee1c37c..323ee9f 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -299,7 +299,7 @@ of which this module provides three different variants: delays, it now always returns the IP address. -.. class:: SimpleHTTPRequestHandler(request, client_address, server) +.. class:: SimpleHTTPRequestHandler(request, client_address, server, directory=None) This class serves files from the current directory and below, directly mapping the directory structure to HTTP requests. @@ -323,6 +323,10 @@ of which this module provides three different variants: ``application/octet-stream``. The mapping is used case-insensitively, and so should contain only lower-cased keys. + .. attribute:: directory + + If not specified, the directory to serve is the current working directory. + The :class:`SimpleHTTPRequestHandler` class defines the following methods: .. method:: do_HEAD() @@ -397,6 +401,14 @@ following command causes the server to bind to localhost only:: .. versionadded:: 3.4 ``--bind`` argument was introduced. +By default, server uses the current directory. The option ``-d/--directory`` +specifies a directory to which it should serve the files. For example, +the following command uses a specific directory:: + + python -m http.server --directory /tmp/ + +.. versionadded:: 3.7 + ``--directory`` specify alternate directory .. class:: CGIHTTPRequestHandler(request, client_address, server) @@ -442,4 +454,3 @@ following command causes the server to bind to localhost only:: the ``--cgi`` option:: python -m http.server --cgi 8000 - |