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

Serve HTML from extensionless URLs in http.server #100463

Closed
jfrost-mo opened this issue Dec 23, 2022 · 5 comments
Closed

Serve HTML from extensionless URLs in http.server #100463

jfrost-mo opened this issue Dec 23, 2022 · 5 comments
Labels
type-feature A feature request or enhancement

Comments

@jfrost-mo
Copy link

jfrost-mo commented Dec 23, 2022

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

@ericvsmith
Copy link
Member

This should be discussed on https://discuss.python.org/c/ideas/6.

I wouldn't support this feature, because http.server isn't meant to be used as a production web server, and I'm concerned about any possible security implications of this.

@jfrost-mo
Copy link
Author

jfrost-mo commented Dec 23, 2022

Fair enough concerns. My thinking is that this would mainly be used for local development before being deployed to a proper webserver for actual use. I'll open a discussion on the discourse and go into more detail about my rational there.

@merwok
Copy link
Member

merwok commented Dec 23, 2022

IMO, if http.server supports serving index.html when found in a directory that matches the URL, then it’s good enough.

@Fraetor
Copy link
Contributor

Fraetor commented Dec 23, 2022

I've opened a discussion on discuss.python.org.

At the very least this issue led to me finding a bug. (#100474)

@jfrost-mo
Copy link
Author

The generally consensus from this discussion is that this is something that is better handled in user code by subclassing the server. As such I'm going to close this issue.

@jfrost-mo jfrost-mo closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants