Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
If you have a directory calledindex.html orindex.htm within a directory (any name inSimpleHTTPRequestHandler.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/ └── bazYour environment
- CPython versions tested on: 3.11.0, Python 3.12.0a3 (c3c7848)
- Operating system and architecture: Fedora Linux 37 (Workstation Edition) x86_64