Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable DirectoryIndex to http.server #76809

Open
epaulson mannequin opened this issue Jan 23, 2018 · 3 comments
Open

Add configurable DirectoryIndex to http.server #76809

epaulson mannequin opened this issue Jan 23, 2018 · 3 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@epaulson
Copy link
Mannequin

epaulson mannequin commented Jan 23, 2018

BPO 32628
Nosy @berkerpeksag, @epaulson
PRs
  • bpo-32628: 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']

    @epaulson
    Copy link
    Mannequin Author

    epaulson mannequin commented Jan 23, 2018

    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?

    @epaulson epaulson mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels Jan 23, 2018
    @berkerpeksag
    Copy link
    Member

    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!)

    @epaulson
    Copy link
    Mannequin Author

    epaulson mannequin commented May 31, 2019

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant