Densaugeo / uploadserver

Python's http.server extended to include a file upload page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make dark mode optional by adding command-line argument `--no-dark-mode`

marvinruder opened this issue · comments

The upload page offers a dark mode feature, whereas the directory lists do not. While many users may find the dark mode a nice gadget, I find it quite irritating when some pages of the same server are shown with light and other with dark background.

Since it is hardly possible to insert custom CSS into http.server’s directory list HTML code (and I tried), it might be useful to be able to turn that feature off completely, e.g. using the command-line argument mentioned above.

It detects dark mode based on your browser/OS preferences, so I'd say the root issue here is that http.server does not detect dark mode. I'd advise you file a bug at https://bugs.python.org/ and ask if they'd accept a PR to add it. If CPython doesn't want to add dark mode support to http.server, then we can reopen this.

Well, that was fast – issue python/cpython#95812 was closed as not planned. Shall we reopen this issue then?

That was indeed quick.

For making dark mode detection optional, I see two obvious options:

  1. Command line option. This is quite simple to implement, but may be hard for people to find. When looking for graphical options on a client, the related server's CLI options are certainly not the first place I look.

  2. Add a client button. It would need to save its state in localStorage. At least two options (forced light mode, dark mode detection) and possibly a third (forced dark mode, if it can be done without adding complexity). This seems to be a fairly common convention so I'm inclined to go this way, provided we can keep the line count low.

Any thoughts or other proposals?

Thanks for reopening!

Letting the client decide would require setting the default mode on every browser or device I (or my friends and colleagues, who I want to upload and download some files) am using. I also would not “clutter” the down-to-the-bare-minimum UI with non-essential options related to other things than upload. So I am still a friend of the CLI argument and see no problem with it being hard to find, as long as it is well documented – maybe adding it to the README can help here. A service’s configuration options documented in this place would be the first thing for me to look at when setting up my own instance, even without specifically looking for a certain feature, I like to know how I can customize it.

If you go for the button option, maybe adding a CLI argument to set the default would be nice, which is then used whenever the client did not (yet) specify a locally stored preferred mode.

That's a good point - I didn't think of cases where you want to set the default behavior for every client that connects. The button + CLI argument to set default would probably be the best user experience, but is more complexity than I want to add, especially when no one has actually asked for a button.

Let's go with your CLI argument proposal for now.

Not sure if you were planning to make another PR for this. If not, I can implement it.

Didn't find the time today, but will probably implement something tomorrow!

Added some basic test cases and readme updates, merged, and published as 3.0.0.