mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
closes bpo-46736: SimpleHTTPRequestHandler now uses HTML5. (GH-31533)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
This commit is contained in:
parent
9bbdde2180
commit
0bb40a42d7
2 changed files with 12 additions and 12 deletions
|
@ -109,11 +109,10 @@ from http import HTTPStatus
|
||||||
|
|
||||||
# Default error message template
|
# Default error message template
|
||||||
DEFAULT_ERROR_MESSAGE = """\
|
DEFAULT_ERROR_MESSAGE = """\
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
<!DOCTYPE HTML>
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
<html lang="en">
|
||||||
<html>
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Error response</title>
|
<title>Error response</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -777,14 +776,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||||
displaypath = urllib.parse.unquote(path)
|
displaypath = urllib.parse.unquote(path)
|
||||||
displaypath = html.escape(displaypath, quote=False)
|
displaypath = html.escape(displaypath, quote=False)
|
||||||
enc = sys.getfilesystemencoding()
|
enc = sys.getfilesystemencoding()
|
||||||
title = 'Directory listing for %s' % displaypath
|
title = f'Directory listing for {displaypath}'
|
||||||
r.append('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" '
|
r.append('<!DOCTYPE HTML>')
|
||||||
'"http://www.w3.org/TR/html4/strict.dtd">')
|
r.append('<html lang="en">')
|
||||||
r.append('<html>\n<head>')
|
r.append('<head>')
|
||||||
r.append('<meta http-equiv="Content-Type" '
|
r.append(f'<meta charset="{enc}">')
|
||||||
'content="text/html; charset=%s">' % enc)
|
r.append(f'<title>{title}</title>\n</head>')
|
||||||
r.append('<title>%s</title>\n</head>' % title)
|
r.append(f'<body>\n<h1>{title}</h1>')
|
||||||
r.append('<body>\n<h1>%s</h1>' % title)
|
|
||||||
r.append('<hr>\n<ul>')
|
r.append('<hr>\n<ul>')
|
||||||
for name in list:
|
for name in list:
|
||||||
fullname = os.path.join(path, name)
|
fullname = os.path.join(path, name)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
:class:`~http.server.SimpleHTTPRequestHandler` now uses HTML5 grammar. Patch
|
||||||
|
by Dong-hee Na.
|
Loading…
Add table
Add a link
Reference in a new issue