@@ -418,49 +418,6 @@ the current directory::
418418such as using different index file names by overriding the class attribute
419419:attr: `index_pages `.
420420
421- .. _http-server-cli :
422-
423- :mod: `http.server ` can also be invoked directly using the :option: `-m `
424- switch of the interpreter. Similar to
425- the previous example, this serves files relative to the current directory::
426-
427- python -m http.server
428-
429- The server listens to port 8000 by default. The default can be overridden
430- by passing the desired port number as an argument::
431-
432- python -m http.server 9000
433-
434- By default, the server binds itself to all interfaces. The option ``-b/--bind ``
435- specifies a specific address to which it should bind. Both IPv4 and IPv6
436- addresses are supported. For example, the following command causes the server
437- to bind to localhost only::
438-
439- python -m http.server --bind 127.0.0.1
440-
441- .. versionchanged :: 3.4
442- Added the ``--bind `` option.
443-
444- .. versionchanged :: 3.8
445- Support IPv6 in the ``--bind `` option.
446-
447- By default, the server uses the current directory. The option ``-d/--directory ``
448- specifies a directory to which it should serve the files. For example,
449- the following command uses a specific directory::
450-
451- python -m http.server --directory /tmp/
452-
453- .. versionchanged :: 3.7
454- Added the ``--directory `` option.
455-
456- By default, the server is conformant to HTTP/1.0. The option ``-p/--protocol ``
457- specifies the HTTP version to which the server is conformant. For example, the
458- following command runs an HTTP/1.1 conformant server::
459-
460- python -m http.server --protocol HTTP/1.1
461-
462- .. versionchanged :: 3.11
463- Added the ``--protocol `` option.
464421
465422.. class :: CGIHTTPRequestHandler(request, client_address, server)
466423
@@ -502,20 +459,80 @@ following command runs an HTTP/1.1 conformant server::
502459 Note that CGI scripts will be run with UID of user nobody, for security
503460 reasons. Problems with the CGI script will be translated to error 403.
504461
505- :class: `CGIHTTPRequestHandler ` can be enabled in the command line by passing
506- the ``--cgi `` option::
507462
508- python -m http.server --cgi
463+ .. _http-server-cli :
464+
465+ Command-line interface
466+ ----------------------
467+
468+ :mod: `http.server ` can also be invoked directly using the :option: `-m `
469+ switch of the interpreter. The following example illustrates how to serve
470+ files relative to the current directory::
471+
472+ python -m http.server [OPTIONS] [port]
473+
474+ The following options are accepted:
475+
476+ .. program :: http.server
477+
478+ .. option :: port
479+
480+ The server listens to port 8000 by default. The default can be overridden
481+ by passing the desired port number as an argument::
482+
483+ python -m http.server 9000
484+
485+ .. option :: -b , --bind <address >
486+
487+ Specifies a specific address to which it should bind. Both IPv4 and IPv6
488+ addresses are supported. By default, the server binds itself to all
489+ interfaces. For example, the following command causes the server to bind
490+ to localhost only::
491+
492+ python -m http.server --bind 127.0.0.1
493+
494+ .. versionadded :: 3.4
495+
496+ .. versionchanged :: 3.8
497+ Support IPv6 in the ``--bind `` option.
498+
499+ .. option :: -d , --directory <dir >
500+
501+ Specifies a directory to which it should serve the files. By default,
502+ the server uses the current directory. For example, the following command
503+ uses a specific directory::
504+
505+ python -m http.server --directory /tmp/
506+
507+ .. versionadded :: 3.7
508+
509+ .. option :: -p , --protocol <version >
510+
511+ Specifies the HTTP version to which the server is conformant. By default,
512+ the server is conformant to HTTP/1.0. For example, the following command
513+ runs an HTTP/1.1 conformant server::
514+
515+ python -m http.server --protocol HTTP/1.1
516+
517+ .. versionadded :: 3.11
518+
519+ .. option :: --cgi
520+
521+ :class: `CGIHTTPRequestHandler ` can be enabled in the command line by passing
522+ the ``--cgi `` option::
523+
524+ python -m http.server --cgi
509525
510526.. warning ::
511527
512- :class: `CGIHTTPRequestHandler ` and the ``--cgi `` command line option
528+ :class: `CGIHTTPRequestHandler ` and the ``--cgi `` command- line option
513529 are not intended for use by untrusted clients and may be vulnerable
514530 to exploitation. Always use within a secure environment.
515531
532+
516533.. _http.server-security :
517534
518- Security Considerations
535+ Security considerations
519536-----------------------
520537
521538.. index :: pair: http.server; security
0 commit comments