[docs] Local host server bug

Julien Palard julien at palard.fr
Mon Jul 8 17:00:38 EDT 2019

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" :)

Julien Palard

More information about the docs mailing list