Why exception from os.path.exists()?
Marko Rauhamaa
marko at pacujo.net
Sun Jun 10 05:06:00 EDT 2018
Chris Angelico <rosuav at gmail.com>:
> It's important to pin down the true cause of the problem, and not
> blame something for doing the proper Pythonic thing.
So could you tell me what the proper Pythonic fix for the example server
in Python's documentation would be?
Here's the code in question:
========================================================================
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
========================================================================
BTW, the proper response would be a 404. 500 means: "There's a bug in my
code".
Marko
More information about the Python-list
mailing list