Skip to content

Commit

Permalink
pythongh-123430: Add dark mode support to pages generated by http.ser…
Browse files Browse the repository at this point in the history
…ver (python#123475)

Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
4 people authored Sep 3, 2024
1 parent 13f61bf commit 9684f40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----

Expand Down
6 changes: 6 additions & 0 deletions Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
:root {
color-scheme: light dark;
}
</style>
<title>Error response</title>
</head>
<body>
Expand Down Expand Up @@ -804,6 +809,7 @@ def list_directory(self, path):
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>')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pages generated by the :mod:`http.server` module allow the browser to apply its default dark mode.

0 comments on commit 9684f40

Please sign in to comment.