mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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
This commit is contained in:
parent
07244a8301
commit
a17a2f52c4
4 changed files with 37 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue