Force dark theme on the Gradio login page

This commit is contained in:
oobabooga 2025-06-19 12:03:19 -07:00
parent 645463b9f0
commit 3344510553
2 changed files with 30 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import builtins
import io
import re
import requests
@ -62,6 +63,13 @@ def my_open(*args, **kwargs):
'\n </head>'
)
file_contents = re.sub(
r'@media \(prefers-color-scheme: dark\) \{\s*body \{([^}]*)\}\s*\}',
r'body.dark {\1}',
file_contents,
flags=re.DOTALL
)
if len(args) > 1 and args[1] == 'rb':
file_contents = file_contents.encode('utf-8')
return io.BytesIO(file_contents)