FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-47063 Add an index_pages default list and parameter to SimpleHTTPRequestHandler by myronww · Pull Request #31985 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 5 additions & 2 deletions Lib/http/server.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):

"""

index_pages = ["index.html", "index.htm"]
server_version = "SimpleHTTP/" + __version__
extensions_map = _encodings_map_default = {
'.gz': 'application/gzip',
Expand All @@ -650,9 +651,11 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
'.xz': 'application/x-xz',
}

def __init__(self, *args, directory=None, **kwargs):
def __init__(self, *args, directory=None, index_pages=None, **kwargs):
if directory is None:
directory = os.getcwd()
if index_pages is not None:
self.index_pages = index_pages
self.directory = os.fspath(directory)
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -696,7 +699,7 @@ def send_head(self):
self.send_header("Content-Length", "0")
self.end_headers()
return None
for index in "index.html", "index.htm":
for index in self.index_pages:
index = os.path.join(path, index)
if os.path.exists(index):
path = index
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add an index_pages parameter to support using non-default index page names.

Back | FazBrowse Home | New Git URL