summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorStéphane Wirtel <stephane@wirtel.be>2017-05-24 07:29:06 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-05-24 07:29:06 (GMT)
commita17a2f52c4c3b37414da95a152fc8669978c7c83 (patch)
treeabf6327c00ac9ae647474b4b63a704a396ba5a58 /Doc
parent07244a83014fad42da937c17d98474b47a570bf7 (diff)
downloadcpython-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')
-rw-r--r--Doc/library/http.server.rst15
-rw-r--r--Doc/whatsnew/3.7.rst5
2 files changed, 18 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
-
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index c305e5a..3195d90 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -139,6 +139,11 @@ If-Modified-Since header. The server returns the 304 response status if the
target file was not modified after the time specified in the header.
(Contributed by Pierre Quentel in :issue:`29654`.)
+Add the parameter ``directory`` to the :class:`~http.server.SimpleHTTPRequestHandler`
+and the ``--directory`` to the command line of the module :mod:`~http.server`.
+With this parameter, the server serves the specified directory, by default it uses the current working directory.
+(Contributed by Stéphane Wirtel and Julien Palard in :issue:`28707`.)
+
locale
------