This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: http.server: on startup, show host/port as URL
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, fxkr, martin.panter, python-dev, r.david.murray, rhettinger
Priority: normal Keywords: patch

Created on 2015-08-20 12:43 by fxkr, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
http_server__on_startup_show_host_and_port_as_url.patch fxkr, 2015-08-20 12:43 review
http_server__on_startup_show_host_and_port_as_url.patch fxkr, 2015-08-20 15:10 review
Messages (8)
msg248882 - (view) Author: Felix Kaiser (fxkr) * Date: 2015-08-20 12:43
http.server: on startup, show host/port as URL


% python3 -m http.server
Serving HTTP on port 8000 ...


% ./python -m http.server  
Serving ...

This is useful because (modern) terminals will auto-detect URLs and make them clickable, so printing an URL makes it easier to navigate the browser there.
msg248886 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-20 14:38
This is a nice idea, but I think it would be better to add it to the message rather than change the message (and we'd still break some people's programs, I'm sure):

  Serving HTTP on port 8000 ( ...
msg248888 - (view) Author: Felix Kaiser (fxkr) * Date: 2015-08-20 15:10
I'm not sure - that'd be redundant, and I find it harder to read. It also breaks for badly configured terminals where "("/")" are part of the select-by-word character set (but thats a very minor issue -- users with parentheses in the set will probably be used to broken links). Here's a new patch though. Your choice :-)

As for breaking programs: that message is clearly intended for human consumption. My opinion is that if someone parses that, they deserve the opportunity to fix their code. However, out of curiosity, I did search for code containing "Serving HTTP on" before opening the issue and couldn't find anything that's parsing that message.
msg248889 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-20 15:24
I do it in a number of test suites (you pass in localhost and port 0, then parse the output to find out what port got used).  I'm sure other people do it as well.  The parens could be dropped.  I don't think it is really redundant, as the two ways of presenting the info hit different parts of my brain: one is the part that looks at things from a networking perspective (ports and IPs) and the other that looks at it from a web perspective (urls).
msg248944 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-08-21 05:47
FWIW, I like Felix's original suggestion.
msg249990 - (view) Author: Felix Kaiser (fxkr) * Date: 2015-09-06 11:41
So do I, but I can live with either way.

Can one of you merge one of these patches?
msg264497 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-29 13:48
New changeset 3be61137280a by Berker Peksag in branch 'default':
Issue #24902: Print server URL on http.server startup
msg264498 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-04-29 13:51
I replaced %-string with str.format(). Thanks!

Note: Please sign the PSF contributor agreement at
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 69090
2016-04-29 13:51:04berker.peksagsetstatus: open -> closed

versions: + Python 3.6
nosy: + berker.peksag

messages: + msg264498
resolution: fixed
stage: resolved
2016-04-29 13:48:23python-devsetnosy: + python-dev
messages: + msg264497
2015-09-06 11:41:44fxkrsetmessages: + msg249990
2015-08-25 07:09:11martin.pantersetnosy: + martin.panter
2015-08-21 05:47:18rhettingersetnosy: + rhettinger
messages: + msg248944
2015-08-20 15:24:13r.david.murraysetmessages: + msg248889
2015-08-20 15:10:03fxkrsetfiles: + http_server__on_startup_show_host_and_port_as_url.patch

messages: + msg248888
2015-08-20 14:38:09r.david.murraysetnosy: + r.david.murray
messages: + msg248886
2015-08-20 12:43:34fxkrcreate