gh-123430: Add dark mode support to pages generated by http.server (#123475)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Yorik Hansen 2024-09-03 08:32:11 +02:00 committed by GitHub
parent 13f61bf7f1
commit 9684f40b9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View File

@ -151,6 +151,14 @@ Added support for converting any objects that have the
(Contributed by Serhiy Storchaka in :gh:`82017`.)
http
----
Directory lists and error pages generated by the :mod:`http.server`
module allow the browser to apply its default dark mode.
(Contributed by Yorik Hansen in :gh:`123430`.)
json
----

View File

@ -114,6 +114,11 @@ DEFAULT_ERROR_MESSAGE = """\
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
:root {
color-scheme: light dark;
}
</style>
<title>Error response</title>
</head>
<body>
@ -804,6 +809,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
r.append('<html lang="en">')
r.append('<head>')
r.append(f'<meta charset="{enc}">')
r.append('<style type="text/css">\n:root {\ncolor-scheme: light dark;\n}\n</style>')
r.append(f'<title>{title}</title>\n</head>')
r.append(f'<body>\n<h1>{title}</h1>')
r.append('<hr>\n<ul>')

View File

@ -0,0 +1 @@
Pages generated by the :mod:`http.server` module allow the browser to apply its default dark mode.