diff options
Diffstat (limited to 'Doc/library/http.server.rst')
-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 - |