Skip to content

Commit c8a5366

Browse files
bpo-46468: document that "-m http.server" defaults to port 8000 (GH-30776)
Code link: https://github.com/python/cpython/blob/70c16468deee9390e34322d32fda57df6e0f46bb/Lib/http/server.py#L1270 It's been this way since at least 3.4. Also improved some wording in the same section.
1 parent ea5b968 commit c8a5366

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Doc/library/http.server.rst

+12-7
Original file line numberDiff line numberDiff line change
@@ -412,32 +412,37 @@ the current directory::
412412
.. _http-server-cli:
413413

414414
:mod:`http.server` can also be invoked directly using the :option:`-m`
415-
switch of the interpreter with a ``port number`` argument. Similar to
415+
switch of the interpreter. Similar to
416416
the previous example, this serves files relative to the current directory::
417417

418-
python -m http.server 8000
418+
python -m http.server
419419

420-
By default, server binds itself to all interfaces. The option ``-b/--bind``
420+
The server listens to port 8000 by default. The default can be overridden
421+
by passing the desired port number as an argument::
422+
423+
python -m http.server 9000
424+
425+
By default, the server binds itself to all interfaces. The option ``-b/--bind``
421426
specifies a specific address to which it should bind. Both IPv4 and IPv6
422427
addresses are supported. For example, the following command causes the server
423428
to bind to localhost only::
424429

425-
python -m http.server 8000 --bind 127.0.0.1
430+
python -m http.server --bind 127.0.0.1
426431

427432
.. versionadded:: 3.4
428433
``--bind`` argument was introduced.
429434

430435
.. versionadded:: 3.8
431436
``--bind`` argument enhanced to support IPv6
432437

433-
By default, server uses the current directory. The option ``-d/--directory``
438+
By default, the server uses the current directory. The option ``-d/--directory``
434439
specifies a directory to which it should serve the files. For example,
435440
the following command uses a specific directory::
436441

437442
python -m http.server --directory /tmp/
438443

439444
.. versionadded:: 3.7
440-
``--directory`` specify alternate directory
445+
``--directory`` argument was introduced.
441446

442447
.. class:: CGIHTTPRequestHandler(request, client_address, server)
443448

@@ -482,4 +487,4 @@ the following command uses a specific directory::
482487
:class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
483488
the ``--cgi`` option::
484489

485-
python -m http.server --cgi 8000
490+
python -m http.server --cgi

0 commit comments

Comments
 (0)