Skip to content

Commit 9684f40

Browse files
YorikHansenZeroIntensityblurb-it[bot]vstinner
authored
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>
1 parent 13f61bf commit 9684f40

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ Added support for converting any objects that have the
151151
(Contributed by Serhiy Storchaka in :gh:`82017`.)
152152

153153

154+
http
155+
----
156+
157+
Directory lists and error pages generated by the :mod:`http.server`
158+
module allow the browser to apply its default dark mode.
159+
(Contributed by Yorik Hansen in :gh:`123430`.)
160+
161+
154162
json
155163
----
156164

Lib/http/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@
114114
<html lang="en">
115115
<head>
116116
<meta charset="utf-8">
117+
<style type="text/css">
118+
:root {
119+
color-scheme: light dark;
120+
}
121+
</style>
117122
<title>Error response</title>
118123
</head>
119124
<body>
@@ -804,6 +809,7 @@ def list_directory(self, path):
804809
r.append('<html lang="en">')
805810
r.append('<head>')
806811
r.append(f'<meta charset="{enc}">')
812+
r.append('<style type="text/css">\n:root {\ncolor-scheme: light dark;\n}\n</style>')
807813
r.append(f'<title>{title}</title>\n</head>')
808814
r.append(f'<body>\n<h1>{title}</h1>')
809815
r.append('<hr>\n<ul>')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pages generated by the :mod:`http.server` module allow the browser to apply its default dark mode.

0 commit comments

Comments
 (0)