summaryrefslogtreecommitdiffstats
path: root/Doc/library/http.server.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/http.server.rst')
-rw-r--r--Doc/library/http.server.rst7
1 files changed, 3 insertions, 4 deletions
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst
index 05ad2d7..8f2ba89 100644
--- a/Doc/library/http.server.rst
+++ b/Doc/library/http.server.rst
@@ -370,10 +370,9 @@ the current directory::
Handler = http.server.SimpleHTTPRequestHandler
- httpd = socketserver.TCPServer(("", PORT), Handler)
-
- print("serving at port", PORT)
- httpd.serve_forever()
+ with socketserver.TCPServer(("", PORT), Handler) as httpd:
+ print("serving at port", PORT)
+ httpd.serve_forever()
.. _http-server-cli: