[Python-checkins] r71093 - python/branches/py3k/Lib/http/server.py
alexandre.vassalotti
python-checkins at python.org
Fri Apr 3 09:16:56 CEST 2009
Author: alexandre.vassalotti
Date: Fri Apr 3 09:16:55 2009
New Revision: 71093
Log:
Make http.server main program nicer for interactive use.
Remove unreachable calls to test().
This restores the behavior of SimpleHTTPServer, where a user could
type "python -m SimpleHTTPServer" and get a simple server for sharing
files. Now, you can do the same thing with "python3 -m http.server".
Modified:
python/branches/py3k/Lib/http/server.py
Modified: python/branches/py3k/Lib/http/server.py
==============================================================================
--- python/branches/py3k/Lib/http/server.py (original)
+++ python/branches/py3k/Lib/http/server.py Fri Apr 3 09:16:55 2009
@@ -1082,10 +1082,12 @@
sa = httpd.socket.getsockname()
print("Serving HTTP on", sa[0], "port", sa[1], "...")
- httpd.serve_forever()
-
+ try:
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ httpd.server_close()
+ sys.exit(0)
if __name__ == '__main__':
- test(HandlerClass=BaseHTTPRequestHandler)
test(HandlerClass=SimpleHTTPRequestHandler)
- test(HandlerClass=CGIHTTPRequestHandler)
More information about the Python-checkins
mailing list