Skip to content
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

http.server: on startup, show host/port as URL #69090

Closed
fxkr mannequin opened this issue Aug 20, 2015 · 8 comments
Closed

http.server: on startup, show host/port as URL #69090

fxkr mannequin opened this issue Aug 20, 2015 · 8 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@fxkr
Copy link
Mannequin

fxkr mannequin commented Aug 20, 2015

BPO 24902
Nosy @rhettinger, @bitdancer, @berkerpeksag, @vadmium
Files
  • http_server__on_startup_show_host_and_port_as_url.patch
  • http_server__on_startup_show_host_and_port_as_url.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-04-29.13:51:04.886>
    created_at = <Date 2015-08-20.12:43:34.050>
    labels = ['type-feature', 'library']
    title = 'http.server: on startup, show host/port as URL'
    updated_at = <Date 2016-04-29.13:51:04.884>
    user = 'https://bugs.python.org/fxkr'

    bugs.python.org fields:

    activity = <Date 2016-04-29.13:51:04.884>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-04-29.13:51:04.886>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-08-20.12:43:34.050>
    creator = 'fxkr'
    dependencies = []
    files = ['40214', '40215']
    hgrepos = []
    issue_num = 24902
    keywords = ['patch']
    message_count = 8.0
    messages = ['248882', '248886', '248888', '248889', '248944', '249990', '264497', '264498']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'r.david.murray', 'python-dev', 'berker.peksag', 'martin.panter', 'fxkr']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue24902'
    versions = ['Python 3.6']

    @fxkr
    Copy link
    Mannequin Author

    fxkr mannequin commented Aug 20, 2015

    http.server: on startup, show host/port as URL

    Old:

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

    New:

    % ./python -m http.server
    Serving http://0.0.0.0:8000/ ...

    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.

    @fxkr fxkr mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 20, 2015
    @bitdancer
    Copy link
    Member

    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 0.0.0.0 port 8000 (http://0.0.0.0:8000) ...

    @fxkr
    Copy link
    Mannequin Author

    fxkr mannequin commented Aug 20, 2015

    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.

    @bitdancer
    Copy link
    Member

    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).

    @rhettinger
    Copy link
    Contributor

    FWIW, I like Felix's original suggestion.

    @fxkr
    Copy link
    Mannequin Author

    fxkr mannequin commented Sep 6, 2015

    So do I, but I can live with either way.

    Can one of you merge one of these patches?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 29, 2016

    New changeset 3be61137280a by Berker Peksag in branch 'default':
    Issue bpo-24902: Print server URL on http.server startup
    https://hg.python.org/cpython/rev/3be61137280a

    @berkerpeksag
    Copy link
    Member

    I replaced %-string with str.format(). Thanks!

    Note: Please sign the PSF contributor agreement at https://www.python.org/psf/contrib/contrib-form/

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants