bpo-36345: Include the code from Tools/scripts/serve.py for the wsgiref-base web server example by matrixise · Pull Request #12562 · python/cpython (original) (raw)
When I tested the example, it wasn't obvious to me how to access the server.
Yep, it's the default output of `Tools/scripts/serve.py`
Maybe the script should display somehow the URL http://localhost:8000/?
Like the output of python -m http.server -d DIRECTORY? I propose to submit an other bpo issue/pull request where we suggest to change the default output of the `Tools/scripts/serve.py` What do you think?
> @@ -25,7 +25,7 @@ def app(environ, respond): return [b'not found'] if __name__ == '__main__': - path = sys.argv[1] + path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000 httpd = simple_server.make_server('', port, app) print("Serving {} on port {}, control-C to stop".format(path, port)) When I press CTRL+C, I get a ResourceWarning. Please add httpd.server_close() after print("\b\bShutting down."). By the way, I'm not sure that "\b" is supported on Windows. I suggest to remove "\b\b" to make the script more portable.
👍