8000 bpo-36211: Change the output with the full URL when executing `make -C Doc/ serve` by matrixise · Pull Request #12195 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-36211: Change the output with the full URL when executing make -C Doc/ serve #12195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bind on 0.0.0.0 and show 127.0.0.1 and improve the print message
  • Loading branch information
matrixise committed Mar 18, 2019
commit 9bad8f4dcafc743e7173bebd405eddc1113e0e3b
10 changes: 6 additions & 4 deletions Tools/scripts/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def app(environ, respond):
path = sys.argv[1]
port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000

# by security, the default interface is the loopback address, 127.0.0.1
httpd = simple_server.make_server('127.0.0.1', port, app)
interface, port = httpd.socket.getsockname()
print("Serving {0} on {1} port {2} (http://{1}:{2}/), control-C to stop".format(path, interface, port))
httpd = simple_server.make_server('', port, app)

message = "Serving {0} on {1} port {3} (http://{2}:{3}/), control-C to stop"
parameters = (path, "0.0.0.0", "127.0.0.1", port)

print(message.format(*parameters))
try:
httpd.serve_forever()
except KeyboardInterrupt:
Expand Down
0