[Python-checkins] cpython: whatsnew: http.server --bind cli option.
r.david.murray
python-checkins at python.org
Mon Feb 24 23:24:43 CET 2014
http://hg.python.org/cpython/rev/1cc737ee45bb
changeset: 89383:1cc737ee45bb
user: R David Murray <rdmurray at bitdance.com>
date: Mon Feb 24 17:21:42 2014 -0500
summary:
whatsnew: http.server --bind cli option.
Also some fixups in the docs.
files:
Doc/library/http.server.rst | 14 ++++++++------
Doc/whatsnew/3.4.rst | 4 ++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst
--- a/Doc/library/http.server.rst
+++ b/Doc/library/http.server.rst
@@ -351,7 +351,7 @@
The :class:`SimpleHTTPRequestHandler` class can be used in the following
manner in order to create a very basic webserver serving files relative to
-the current directory. ::
+the current directory::
import http.server
import socketserver
@@ -365,15 +365,17 @@
print("serving at port", PORT)
httpd.serve_forever()
+.. _http-server-cli:
+
:mod:`http.server` can also be invoked directly using the :option:`-m`
switch of the interpreter with a ``port number`` argument. Similar to
-the previous example, this serves files relative to the current directory. ::
+the previous example, this serves files relative to the current directory::
python -m http.server 8000
-By default, server binds itself to all interfaces. To restrict it to bind to a
-particular interface only, ``--bind ADDRESS`` argument can be used. For e.g, to
-restrict the server to bind only to localhost. ::
+By default, server binds itself to all interfaces. The option ``-b/--bind``
+specifies a specific address to which it should bind. For example, the
+following command causes the server to bind to localhost only::
python -m http.server 8000 --bind 127.0.0.1
@@ -422,7 +424,7 @@
reasons. Problems with the CGI script will be translated to error 403.
:class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
-the ``--cgi`` option.::
+the ``--cgi`` option::
python -m http.server --cgi 8000
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -801,6 +801,10 @@
:attr:`~http.server.HTTP.error_message_format` attribute and sent as the body
of the error response. (Contributed by Karl Cow in :issue:`12921`.)
+The :mod:`http.server` :ref:`command line interface <http-server-cli>` now has
+a ``-b/--bind`` option that causes the server to listen on a specific address.
+(Contributed by Malte Swart in :issue:`17764`.)
+
importlib
---------
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list