Search code examples
pythonhttpserverdirectoryindex

Disable index files with SimpleHTTPServer


By default, SimpleHTTPServer uses index.html as a index file, I would like to disable them and always show a directory index.

How can I do that? The document here says nothing about it


Solution

  • I should be overwriting the send_head method

    Simply disable the following lines

            for index in "index.html", "index.htm":
                index = os.path.join(path, index)
                if os.path.exists(index):
                    path = index
                    break