Skip to content

Commit 1797dcd

Browse files
authored
[3.13] Docs: Use bash lexer for http.server CLI commands, not Python (GH-148612) (#148621)
1 parent a5969e8 commit 1797dcd

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Doc/library/http.server.rst

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ provides three different variants:
5959

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

@@ -201,7 +201,7 @@ provides three different variants:
201201
request header it responds back with a ``100 Continue`` followed by ``200
202202
OK`` headers.
203203
This method can be overridden to raise an error if the server does not
204-
want the client to continue. For e.g. server can choose to send ``417
204+
want the client to continue. For example, the server can choose to send ``417
205205
Expectation Failed`` as a response header and ``return False``.
206206

207207
.. versionadded:: 3.2
@@ -478,7 +478,9 @@ Command-line interface
478478

479479
:mod:`http.server` can also be invoked directly using the :option:`-m`
480480
switch of the interpreter. The following example illustrates how to serve
481-
files relative to the current directory::
481+
files relative to the current directory:
482+
483+
.. code-block:: bash
482484
483485
python -m http.server [OPTIONS] [port]
484486
@@ -489,7 +491,9 @@ The following options are accepted:
489491
.. option:: port
490492

491493
The server listens to port 8000 by default. The default can be overridden
492-
by passing the desired port number as an argument::
494+
by passing the desired port number as an argument:
495+
496+
.. code-block:: bash
493497
494498
python -m http.server 9000
495499
@@ -498,7 +502,9 @@ The following options are accepted:
498502
Specifies a specific address to which it should bind. Both IPv4 and IPv6
499503
addresses are supported. By default, the server binds itself to all
500504
interfaces. For example, the following command causes the server to bind
501-
to localhost only::
505+
to localhost only:
506+
507+
.. code-block:: bash
502508
503509
python -m http.server --bind 127.0.0.1
504510
@@ -511,7 +517,9 @@ The following options are accepted:
511517

512518
Specifies a directory to which it should serve the files. By default,
513519
the server uses the current directory. For example, the following command
514-
uses a specific directory::
520+
uses a specific directory:
521+
522+
.. code-block:: bash
515523
516524
python -m http.server --directory /tmp/
517525
@@ -521,7 +529,9 @@ The following options are accepted:
521529

522530
Specifies the HTTP version to which the server is conformant. By default,
523531
the server is conformant to HTTP/1.0. For example, the following command
524-
runs an HTTP/1.1 conformant server::
532+
runs an HTTP/1.1 conformant server:
533+
534+
.. code-block:: bash
525535
526536
python -m http.server --protocol HTTP/1.1
527537
@@ -530,7 +540,9 @@ The following options are accepted:
530540
.. option:: --cgi
531541

532542
:class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
533-
the ``--cgi`` option::
543+
the ``--cgi`` option:
544+
545+
.. code-block:: bash
534546
535547
python -m http.server --cgi
536548
@@ -559,7 +571,7 @@ to be served.
559571

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

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

0 commit comments

Comments
 (0)