Skip to content

Serve HTML from extensionless URLs in http.server #100463

@jfrost-mo

Description

@jfrost-mo

Feature or enhancement

Add handling for extensionless URLs in http.server

For example if you have a folder containing foo.html and run python3 -m http.server from it, you would be able to use the URL http://localhost:8000/foo rather than having to use http://localhost:8000/foo.html.

Pitch

A common pattern in URL design is to omit the file extension for pages, as this
both makes the URL look nicer and makes it technology agnostic (it doesn't
matter if the page is written in PHP or HTML).

The motivation for this change is the common use case of the python HTTP server
for static website development, especially amongst those learning HTML/CSS.
This change allows them to use the best practice of omitting extensions in
links and still having navigation between multiple pages working.

Previous discussion

Needs to have one on https://discuss.python.org/c/ideas/6.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions