diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2022-02-23 17:59:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 17:59:32 (GMT) |
commit | 0bb40a42d71873ea267aace8c92a02d66fe36dc2 (patch) | |
tree | 482989247863a2d729848c6a6cde081f4fb82ef8 /Lib/http | |
parent | 9bbdde218005f552304d9954bb97e3f9185edded (diff) | |
download | cpython-0bb40a42d71873ea267aace8c92a02d66fe36dc2.zip cpython-0bb40a42d71873ea267aace8c92a02d66fe36dc2.tar.gz cpython-0bb40a42d71873ea267aace8c92a02d66fe36dc2.tar.bz2 |
closes bpo-46736: SimpleHTTPRequestHandler now uses HTML5. (GH-31533)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/server.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 194a503..a6100d4 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -109,11 +109,10 @@ from http import HTTPStatus # Default error message template DEFAULT_ERROR_MESSAGE = """\ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" - "http://www.w3.org/TR/html4/strict.dtd"> -<html> +<!DOCTYPE HTML> +<html lang="en"> <head> - <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> + <meta charset="utf-8"> <title>Error response</title> </head> <body> @@ -777,14 +776,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): displaypath = urllib.parse.unquote(path) displaypath = html.escape(displaypath, quote=False) enc = sys.getfilesystemencoding() - title = 'Directory listing for %s' % displaypath - r.append('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ' - '"http://www.w3.org/TR/html4/strict.dtd">') - r.append('<html>\n<head>') - r.append('<meta http-equiv="Content-Type" ' - 'content="text/html; charset=%s">' % enc) - r.append('<title>%s</title>\n</head>' % title) - r.append('<body>\n<h1>%s</h1>' % title) + title = f'Directory listing for {displaypath}' + r.append('<!DOCTYPE HTML>') + r.append('<html lang="en">') + r.append('<head>') + r.append(f'<meta charset="{enc}">') + r.append(f'<title>{title}</title>\n</head>') + r.append(f'<body>\n<h1>{title}</h1>') r.append('<hr>\n<ul>') for name in list: fullname = os.path.join(path, name) |