[docs] Local host server bug

Ngoc Bach Nguyen ngocbachpol at gmail.com
Mon Jul 8 18:09:44 EDT 2019


Thank you very much! I did not expect to receive a reply this early, and I
am really grateful for your help. Anyway, best wishes to you and your work!

On Mon, Jul 8, 2019, 23:00 Julien Palard <julien at palard.fr> wrote:

> Hi Bach,
>
> > I started a local host server using python3 -m http.server
> > Instead of the directory, it opens "index.html" all the time.
>
> It's not even a bug, it's a convention:
> https://en.wikipedia.org/wiki/Webserver_directory_index
>
> In other words there's two cases:
>  - Either the URL points to a file, the file is served, no surprises.
>  - Either the URL points to a directory, and here there's a choice :
> Either display a "directory listing" or pick a file and display this file.
>
> I don't really know about a formal specification around "index.html", I
> think it's just a consensus that arose by itself, "it has always been like
> this".
>
> It's also documented in SimpleHttpRequestHandler:
> > If the request was mapped to a directory, the directory is checked for a
> file named `index.html`
> > or `index.htm` (in that order). If found, the file’s contents are
> returned; otherwise a directory listing
> > is generated by calling the `list_directory()` method.
>
> _
> https://docs.python.org/3/library/http.server.html#http.server.SimpleHTTPRequestHandler.do_GET
>
> If you think it should be documented also elsewhere, don't hesitate to
> propose it (like: where you searched?).
>
> > Took me 2 days to diagnose the problem
>
> I hope you learned a lot during this "trip" :)
>
> Bests,
> --
> Julien Palard
> https://mdk.fr
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190709/049310da/attachment-0001.html>


More information about the docs mailing list