Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ instantiation, of which this module provides three different variants:

This class is used to handle the HTTP requests that arrive at the server. By
itself, it cannot respond to any actual HTTP requests; it must be subclassed
to handle each request method (e.g. GET or POST).
to handle each request method (for example, ``'GET'`` or ``'POST'``).
:class:`BaseHTTPRequestHandler` provides a number of class and instance
variables, and methods for use by subclasses.

Expand Down Expand Up @@ -241,7 +241,7 @@ instantiation, of which this module provides three different variants:
request header it responds back with a ``100 Continue`` followed by ``200
OK`` headers.
This method can be overridden to raise an error if the server does not
want the client to continue. For e.g. server can choose to send ``417
want the client to continue. For example, the server can choose to send ``417
Expectation Failed`` as a response header and ``return False``.

.. versionadded:: 3.2
Expand Down Expand Up @@ -469,7 +469,9 @@ Command-line interface

:mod:`!http.server` can also be invoked directly using the :option:`-m`
switch of the interpreter. The following example illustrates how to serve
files relative to the current directory::
files relative to the current directory:

.. code-block:: bash

python -m http.server [OPTIONS] [port]

Expand All @@ -480,7 +482,9 @@ The following options are accepted:
.. option:: port

The server listens to port 8000 by default. The default can be overridden
by passing the desired port number as an argument::
by passing the desired port number as an argument:

.. code-block:: bash

python -m http.server 9000

Expand All @@ -489,7 +493,9 @@ The following options are accepted:
Specifies a specific address to which it should bind. Both IPv4 and IPv6
addresses are supported. By default, the server binds itself to all
interfaces. For example, the following command causes the server to bind
to localhost only::
to localhost only:

.. code-block:: bash

python -m http.server --bind 127.0.0.1

Expand All @@ -502,7 +508,9 @@ The following options are accepted:

Specifies a directory to which it should serve the files. By default,
the server uses the current directory. For example, the following command
uses a specific directory::
uses a specific directory:

.. code-block:: bash

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

Expand All @@ -512,15 +520,19 @@ The following options are accepted:

Specifies the HTTP version to which the server is conformant. By default,
the server is conformant to HTTP/1.0. For example, the following command
runs an HTTP/1.1 conformant server::
runs an HTTP/1.1 conformant server:

.. code-block:: bash

python -m http.server --protocol HTTP/1.1

.. versionadded:: 3.11

.. option:: --tls-cert

Specifies a TLS certificate chain for HTTPS connections::
Specifies a TLS certificate chain for HTTPS connections:

.. code-block:: bash

python -m http.server --tls-cert fullchain.pem

Expand All @@ -536,14 +548,16 @@ The following options are accepted:

.. option:: --tls-password-file

Specifies the password file for password-protected private keys::
Specifies the password file for password-protected private keys:

.. code-block:: bash

python -m http.server \
--tls-cert cert.pem \
--tls-key key.pem \
--tls-password-file password.txt

This option requires `--tls-cert`` to be specified.
This option requires ``--tls-cert`` to be specified.

.. versionadded:: 3.14

Expand All @@ -561,7 +575,7 @@ to be served.

Methods :meth:`BaseHTTPRequestHandler.send_header` and
:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input
and does not perform input validation such as checking for the presence of CRLF
and do not perform input validation such as checking for the presence of CRLF
sequences. Untrusted input may result in HTTP Header injection attacks.

Earlier versions of Python did not scrub control characters from the
Expand Down
Loading