mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
For this server to work on Windows, directories should use "/" as the
separator in the href, not os.sep. Added a <title> tag to directory listings. Bumped version to 0.5.
This commit is contained in:
parent
410a84441d
commit
1d105d15d3
1 changed files with 3 additions and 2 deletions
|
@ -6,7 +6,7 @@ and HEAD requests in a fairly straightforward manner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.4"
|
__version__ = "0.5"
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -99,6 +99,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
return None
|
return None
|
||||||
list.sort(lambda a, b: cmp(a.lower(), b.lower()))
|
list.sort(lambda a, b: cmp(a.lower(), b.lower()))
|
||||||
f = StringIO()
|
f = StringIO()
|
||||||
|
f.write("<title>Directory listing for %s</title>\n" % self.path)
|
||||||
f.write("<h2>Directory listing for %s</h2>\n" % self.path)
|
f.write("<h2>Directory listing for %s</h2>\n" % self.path)
|
||||||
f.write("<hr>\n<ul>\n")
|
f.write("<hr>\n<ul>\n")
|
||||||
for name in list:
|
for name in list:
|
||||||
|
@ -107,7 +108,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
# Append / for directories or @ for symbolic links
|
# Append / for directories or @ for symbolic links
|
||||||
if os.path.isdir(fullname):
|
if os.path.isdir(fullname):
|
||||||
displayname = name + "/"
|
displayname = name + "/"
|
||||||
linkname = name + os.sep
|
linkname = name + "/"
|
||||||
if os.path.islink(fullname):
|
if os.path.islink(fullname):
|
||||||
displayname = name + "@"
|
displayname = name + "@"
|
||||||
# Note: a link to a directory displays with @ and links with /
|
# Note: a link to a directory displays with @ and links with /
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue