Skip to content

Commit 0968f33

Browse files
[3.14] Docs: Use bash lexer for http.server CLI commands, not Python (GH-148612) (#148620)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent bfbabb5 commit 0968f33

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Doc/library/http.server.rst

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ instantiation, of which this module provides three different variants:
9999

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

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

247247
.. versionadded:: 3.2
@@ -518,7 +518,9 @@ Command-line interface
518518

519519
:mod:`!http.server` can also be invoked directly using the :option:`-m`
520520
switch of the interpreter. The following example illustrates how to serve
521-
files relative to the current directory::
521+
files relative to the current directory:
522+
523+
.. code-block:: bash
522524
523525
python -m http.server [OPTIONS] [port]
524526
@@ -529,7 +531,9 @@ The following options are accepted:
529531
.. option:: port
530532

531533
The server listens to port 8000 by default. The default can be overridden
532-
by passing the desired port number as an argument::
534+
by passing the desired port number as an argument:
535+
536+
.. code-block:: bash
533537
534538
python -m http.server 9000
535539
@@ -538,7 +542,9 @@ The following options are accepted:
538542
Specifies a specific address to which it should bind. Both IPv4 and IPv6
539543
addresses are supported. By default, the server binds itself to all
540544
interfaces. For example, the following command causes the server to bind
541-
to localhost only::
545+
to localhost only:
546+
547+
.. code-block:: bash
542548
543549
python -m http.server --bind 127.0.0.1
544550
@@ -551,7 +557,9 @@ The following options are accepted:
551557

552558
Specifies a directory to which it should serve the files. By default,
553559
the server uses the current directory. For example, the following command
554-
uses a specific directory::
560+
uses a specific directory:
561+
562+
.. code-block:: bash
555563
556564
python -m http.server --directory /tmp/
557565
@@ -561,7 +569,9 @@ The following options are accepted:
561569

562570
Specifies the HTTP version to which the server is conformant. By default,
563571
the server is conformant to HTTP/1.0. For example, the following command
564-
runs an HTTP/1.1 conformant server::
572+
runs an HTTP/1.1 conformant server:
573+
574+
.. code-block:: bash
565575
566576
python -m http.server --protocol HTTP/1.1
567577
@@ -587,7 +597,9 @@ The following options are accepted:
587597

588598
.. option:: --tls-cert
589599

590-
Specifies a TLS certificate chain for HTTPS connections::
600+
Specifies a TLS certificate chain for HTTPS connections:
601+
602+
.. code-block:: bash
591603
592604
python -m http.server --tls-cert fullchain.pem
593605
@@ -603,14 +615,16 @@ The following options are accepted:
603615

604616
.. option:: --tls-password-file
605617

606-
Specifies the password file for password-protected private keys::
618+
Specifies the password file for password-protected private keys:
619+
620+
.. code-block:: bash
607621
608622
python -m http.server \
609623
--tls-cert cert.pem \
610624
--tls-key key.pem \
611625
--tls-password-file password.txt
612626
613-
This option requires `--tls-cert`` to be specified.
627+
This option requires ``--tls-cert`` to be specified.
614628

615629
.. versionadded:: 3.14
616630

@@ -628,7 +642,7 @@ to be served.
628642

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

634648
Earlier versions of Python did not scrub control characters from the

0 commit comments

Comments
 (0)