diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-01-22 15:31:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 15:31:40 (GMT) |
commit | b4088801db4b4f56b177b1c01dd873c7922e6a9f (patch) | |
tree | d66b05b74b2fb095815f5d18bd67b34b33b54ca3 /Doc/library/http.server.rst | |
parent | f1796f29478f08f34e0c30a060622c0b2d843e2c (diff) | |
download | cpython-b4088801db4b4f56b177b1c01dd873c7922e6a9f.zip cpython-b4088801db4b4f56b177b1c01dd873c7922e6a9f.tar.gz cpython-b4088801db4b4f56b177b1c01dd873c7922e6a9f.tar.bz2 |
bpo-46468: document that "-m http.server" defaults to port 8000 (GH-30776) (#30786)
Code link:
https://github.com/python/cpython/blob/70c16468deee9390e34322d32fda57df6e0f46bb/Lib/http/server.pyGH-L1270
It's been this way since at least 3.4.
Also improved some wording in the same section.
(cherry picked from commit c8a536624e8f5d6612e3c275c5b19592583a8cf8)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Doc/library/http.server.rst')
-rw-r--r-- | Doc/library/http.server.rst | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index 08b0ddf..dea7910 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -412,17 +412,22 @@ the current directory:: .. _http-server-cli: :mod:`http.server` can also be invoked directly using the :option:`-m` -switch of the interpreter with a ``port number`` argument. Similar to +switch of the interpreter. Similar to the previous example, this serves files relative to the current directory:: - python -m http.server 8000 + python -m http.server -By default, server binds itself to all interfaces. The option ``-b/--bind`` +The server listens to port 8000 by default. The default can be overridden +by passing the desired port number as an argument:: + + python -m http.server 9000 + +By default, the server binds itself to all interfaces. The option ``-b/--bind`` specifies a specific address to which it should bind. Both IPv4 and IPv6 addresses are supported. For example, the following command causes the server to bind to localhost only:: - python -m http.server 8000 --bind 127.0.0.1 + python -m http.server --bind 127.0.0.1 .. versionadded:: 3.4 ``--bind`` argument was introduced. @@ -430,14 +435,14 @@ to bind to localhost only:: .. versionadded:: 3.8 ``--bind`` argument enhanced to support IPv6 -By default, server uses the current directory. The option ``-d/--directory`` +By default, the 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 + ``--directory`` argument was introduced. .. class:: CGIHTTPRequestHandler(request, client_address, server) @@ -482,4 +487,4 @@ the following command uses a specific directory:: :class:`CGIHTTPRequestHandler` can be enabled in the command line by passing the ``--cgi`` option:: - python -m http.server --cgi 8000 + python -m http.server --cgi |