summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorYorik Hansen <github@yorik.dev>2024-09-03 06:32:11 (GMT)
committerGitHub <noreply@github.com>2024-09-03 06:32:11 (GMT)
commit9684f40b9f51816fd326f1b4957ea5fb5b5922c8 (patch)
treec2a206ade99224a348e88c26072ab9f32c153a2a /Lib/http
parent13f61bf7f1fb9b9b109b089610e845d98e6dc937 (diff)
downloadcpython-9684f40b9f51816fd326f1b4957ea5fb5b5922c8.zip
cpython-9684f40b9f51816fd326f1b4957ea5fb5b5922c8.tar.gz
cpython-9684f40b9f51816fd326f1b4957ea5fb5b5922c8.tar.bz2
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>
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/server.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 2d01064..a6f7aec 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -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>')