From 9684f40b9f51816fd326f1b4957ea5fb5b5922c8 Mon Sep 17 00:00:00 2001 From: Yorik Hansen Date: Tue, 3 Sep 2024 08:32:11 +0200 Subject: [PATCH] gh-123430: Add dark mode support to pages generated by http.server (#123475) Co-authored-by: Peter Bierma Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Victor Stinner --- Doc/whatsnew/3.14.rst | 8 ++++++++ Lib/http/server.py | 6 ++++++ .../2024-08-29-14-51-36.gh-issue-123430.M7wXl9.rst | 1 + 3 files changed, 15 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-08-29-14-51-36.gh-issue-123430.M7wXl9.rst diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 4817c5258052e1..233d7ce0399cd6 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -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 ---- diff --git a/Lib/http/server.py b/Lib/http/server.py index 2d010649e56b51..a6f7aecc78763f 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -114,6 +114,11 @@ + Error response @@ -804,6 +809,7 @@ def list_directory(self, path): r.append('') r.append('') r.append(f'') + r.append('') r.append(f'{title}\n') r.append(f'\n

{title}

') r.append('
\n
    ') diff --git a/Misc/NEWS.d/next/Library/2024-08-29-14-51-36.gh-issue-123430.M7wXl9.rst b/Misc/NEWS.d/next/Library/2024-08-29-14-51-36.gh-issue-123430.M7wXl9.rst new file mode 100644 index 00000000000000..0afdad7917fa8f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-08-29-14-51-36.gh-issue-123430.M7wXl9.rst @@ -0,0 +1 @@ +Pages generated by the :mod:`http.server` module allow the browser to apply its default dark mode.