<!-- If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not the right place to seek help. Consider the following options instead: - reading the Python tutorial: https://docs.python.org/3/tutorial/ - posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7 - emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list - searching our issue tracker (https://github.com/python/cpython/issues) to see if your problem has already been reported --> # Bug report If you have a directory called `index.html` or `index.htm` within a directory (any name in `SimpleHTTPRequestHandler.index_pages`), it causes http.server to return a 404 Not Found error instead of the directory listing. This comes about due to not checking that the index is a regular file when it checks for its presence. The 404 error comes from the call to open() the directory raising an OSError. To reproduce create a folder structure like below and run python3 -m http.server -d foo. You will get a 404 error rather than a directory listing. ``` foo/ foo/ ├── bar └── index.html/ └── baz ``` # Your environment <!-- Include as many relevant details as possible about the environment you experienced the bug in --> - CPython versions tested on: 3.11.0, Python 3.12.0a3 (c3c7848a) - Operating system and architecture: Fedora Linux 37 (Workstation Edition) x86_64 <!-- You can freely edit this text. Remove any lines you believe are unnecessary. --> <!-- gh-linked-prs --> ### Linked PRs * gh-100475 * gh-100504 * gh-100505 <!-- /gh-linked-prs -->