GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add configurable DirectoryIndex to http.server · Issue #76809 · python/cpython

Add configurable DirectoryIndex to http.server #76809

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Add configurable DirectoryIndex to http.server#76809
Copy link
Labels
3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

Description

epaulson
mannequin
opened on Jan 23, 2018
Issue body actions
BPO 32628
Nosy @berkerpeksag, @epaulson
PRs
  • gh-76809: support DirectoryIndex for http server #5308
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2018-01-23.04:16:45.000>
    labels = ['3.7', 'library']
    title = 'Add configurable DirectoryIndex to http.server'
    updated_at = <Date 2019-05-31.22:47:17.231>
    user = 'https://github.com/epaulson'

    bugs.python.org fields:

    activity = <Date 2019-05-31.22:47:17.231>
    actor = 'epaulson'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2018-01-23.04:16:45.000>
    creator = 'epaulson'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32628
    keywords = ['patch']
    message_count = 3.0
    messages = ['310468', '344129', '344137']
    nosy_count = 2.0
    nosy_names = ['berker.peksag', 'epaulson']
    pr_nums = ['5308']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue32628'
    versions = ['Python 3.7']

    Activity

    1. epaulson commented on Jan 23, 2018

      @epaulson
      epaulsonmannequin
      on Jan 23, 2018
      MannequinAuthor
      More actions

      In http.server and SimpleHTTPRequestHandler - the send_head function is hard-coded to treat index.html and index.htm as files to return in a directory - if neither of those files are present, it lists the directory.

      It would be very nice to be able to specify other files to use as a directory index, similar to the DirectoryIndex directive from Apache.

      I think it'd be straight forward to add some kind of list you could set, just like you can modify extensions_map to include other types of MIME types.

      Would it be OK to just add a directory_index list with index.html and index.htm on by default that people could do like
      Handler.directory_index.append("index.htmlx") in their setup? Or would such an API be better with some kind of helper?

    2. epaulson
      added
      3.7 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Jan 23, 2018
    3. berkerpeksag commented on May 31, 2019

      @berkerpeksag
      berkerpeksag
      on May 31, 2019
      Member
      More actions

      Thank you for the report and for the patch!

      What's your use case? I understand the need for it for httpd, but as someone who uses http.server daily, I can't think of a use case that I'd find this feature useful. Note that even the example in your message and the test in the patch use artificial file names :)

      Handler.directory_index.append("index.htmlx") API doesn't look good to me. It would be nice to subclass it, but that would make http.server less usable (especially if you run it via "python -m http.server")

      I suggest closing this as 'rejected' (sorry!)

    4. epaulson commented on May 31, 2019

      @epaulson
      epaulsonmannequin
      on May 31, 2019
      MannequinAuthor
      More actions

      I think my use case was Sharepoint and static site generators - Sharepoint can serve a tree of .aspx files as raw HTML, but maddeningly not .html files. The site generator we used spit out a fairly complicated site where the internal links point at directories counting on the fact that it is served correctly by the directoryindex handler. The site generator spits out .aspx but http.server can't serve them.

      A directory full of .xhtml files would have similar problems, which certainly still exist in the wild.

      The example in the test was named index.test because it's creating files on the disk in the test, shared by other parts of the test, and I wanted to be clear about what it was. It was not intended to be an example use case.

    5. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    6. serhiy-storchaka
      added this to HTTP issueson Jul 3, 2026
    7. github-project-automation
      moved this to Todo in HTTP issueson Jul 3, 2026
    8. soreavis commented on Jul 13, 2026

      @soreavis
      soreavis
      on Jul 13, 2026
      Contributor
      More actions

      This looks resolved — index_pages was added to SimpleHTTPRequestHandler in 3.12 via gh-91219, and it's a documented class attribute you can override:

      class Handler(http.server.SimpleHTTPRequestHandler):
          index_pages = ("index.aspx",)

      That covers the .aspx and .xhtml cases from this thread. Worth closing this and #5308 as superseded?

    9. serhiy-storchaka
      closed this as a duplicateof SimpleHTTPRequestHandler has hard coded index page list. #91219 on Aug 13, 2026
    10. github-project-automation
      moved this from Todo to Done in HTTP issueson Aug 13, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

      Projects

      • HTTP issues
        Status
        Done
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.