]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs: Use bash lexer for http.server CLI commands, not Python (#148612)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Wed, 15 Apr 2026 15:18:49 +0000 (18:18 +0300)
committerGitHub <noreply@github.com>
Wed, 15 Apr 2026 15:18:49 +0000 (18:18 +0300)
Doc/library/http.server.rst

index cb8b5f0df88d6cb594a926db2305e9f0dd40c6c9..33ecaae5c87b0123f0e8f05cee533a26ebd29032 100644 (file)
@@ -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.
 
@@ -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
@@ -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]
 
@@ -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
 
@@ -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
 
@@ -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/
 
@@ -512,7 +520,9 @@ 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
 
@@ -520,7 +530,9 @@ The following options are accepted:
 
 .. 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
 
@@ -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
 
@@ -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