Skip to content

Commit 55c9d60

Browse files
authored
Docs: Use bash lexer for http.server CLI commands, not Python (#148612)
1 parent 70eb56b commit 55c9d60

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
@@ -469,7 +469,9 @@ Command-line interface
469469

470470
:mod:`!http.server` can also be invoked directly using the :option:`-m`
471471
switch of the interpreter. The following example illustrates how to serve
472-
files relative to the current directory::
472+
files relative to the current directory:
473+
474+
.. code-block:: bash
473475
474476
python -m http.server [OPTIONS] [port]
475477
@@ -480,7 +482,9 @@ The following options are accepted:
480482
.. option:: port
481483

482484
The server listens to port 8000 by default. The default can be overridden
483-
by passing the desired port number as an argument::
485+
by passing the desired port number as an argument:
486+
487+
.. code-block:: bash
484488
485489
python -m http.server 9000
486490
@@ -489,7 +493,9 @@ The following options are accepted:
489493
Specifies a specific address to which it should bind. Both IPv4 and IPv6
490494
addresses are supported. By default, the server binds itself to all
491495
interfaces. For example, the following command causes the server to bind
492-
to localhost only::
496+
to localhost only:
497+
498+
.. code-block:: bash
493499
494500
python -m http.server --bind 127.0.0.1
495501
@@ -502,7 +508,9 @@ The following options are accepted:
502508

503509
Specifies a directory to which it should serve the files. By default,
504510
the server uses the current directory. For example, the following command
505-
uses a specific directory::
511+
uses a specific directory:
512+
513+
.. code-block:: bash
506514
507515
python -m http.server --directory /tmp/
508516
@@ -512,15 +520,19 @@ The following options are accepted:
512520

513521
Specifies the HTTP version to which the server is conformant. By default,
514522
the server is conformant to HTTP/1.0. For example, the following command
515-
runs an HTTP/1.1 conformant server::
523+
runs an HTTP/1.1 conformant server:
524+
525+
.. code-block:: bash
516526
517527
python -m http.server --protocol HTTP/1.1
518528
519529
.. versionadded:: 3.11
520530

521531
.. option:: --tls-cert
522532

523-
Specifies a TLS certificate chain for HTTPS connections::
533+
Specifies a TLS certificate chain for HTTPS connections:
534+
535+
.. code-block:: bash
524536
525537
python -m http.server --tls-cert fullchain.pem
526538
@@ -536,14 +548,16 @@ The following options are accepted:
536548

537549
.. option:: --tls-password-file
538550

539-
Specifies the password file for password-protected private keys::
551+
Specifies the password file for password-protected private keys:
552+
553+
.. code-block:: bash
540554
541555
python -m http.server \
542556
--tls-cert cert.pem \
543557
--tls-key key.pem \
544558
--tls-password-file password.txt
545559
546-
This option requires `--tls-cert`` to be specified.
560+
This option requires ``--tls-cert`` to be specified.
547561

548562
.. versionadded:: 3.14
549563

@@ -561,7 +575,7 @@ to be served.
561575

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

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

0 commit comments

Comments
 (0)