Sunil Surendra Singh commited on
Commit
a9e230c
·
1 Parent(s): 3253a7e

made darkmode as default when app starts

Browse files
Files changed (2) hide show
  1. app.py +20 -14
  2. config.py +6 -0
app.py CHANGED
@@ -9,25 +9,31 @@ def clear():
9
 
10
 
11
  def create_interface():
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  with gr.Blocks(
13
  title=app_config.title, theme=app_config.theme, css=app_config.css
14
  ) as app:
15
- # Dark mode toggle functionality
 
16
  with gr.Row():
17
- darkmode_checkbox = gr.Checkbox(label="Dark Mode", value=False)
 
 
 
18
  darkmode_checkbox.change(
19
- None,
20
- None,
21
- None,
22
- _js="""() => {
23
- if (document.querySelectorAll('.dark').length) {
24
- document.querySelector('body').classList.remove('dark');
25
- } else {
26
- document.querySelector('body').classList.add('dark');
27
- }
28
- }
29
- """,
30
- api_name=False,
31
  )
32
  with gr.Row():
33
  with gr.Column():
 
9
 
10
 
11
  def create_interface():
12
+ js_enable_darkmode = """() =>
13
+ {
14
+ document.querySelector('body').classList.add('dark');
15
+ }"""
16
+ js_toggle_darkmode = """() =>
17
+ {
18
+ if (document.querySelectorAll('.dark').length) {
19
+ document.querySelector('body').classList.remove('dark');
20
+ } else {
21
+ document.querySelector('body').classList.add('dark');
22
+ }
23
+ }"""
24
+
25
  with gr.Blocks(
26
  title=app_config.title, theme=app_config.theme, css=app_config.css
27
  ) as app:
28
+ # enable darkmode
29
+ app.load(fn=None, inputs=None, outputs=None, _js=js_enable_darkmode)
30
  with gr.Row():
31
+ darkmode_checkbox = gr.Checkbox(
32
+ label="Dark Mode", value=True, interactive=True
33
+ )
34
+ # toggle darkmode on/off when checkbox is checked/unchecked
35
  darkmode_checkbox.change(
36
+ None, None, None, _js=js_toggle_darkmode, api_name=False
 
 
 
 
 
 
 
 
 
 
 
37
  )
38
  with gr.Row():
39
  with gr.Column():
config.py CHANGED
@@ -52,6 +52,12 @@ class AppConfig:
52
  "Third-Person Limited",
53
  "Third-Person Omniscient",
54
  ]
 
 
 
 
 
 
55
 
56
 
57
  app_config = AppConfig()
 
52
  "Third-Person Limited",
53
  "Third-Person Omniscient",
54
  ]
55
+ HF_TOKEN = "Bearer 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"
56
+ OPENAI_KEY = "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"
57
+ I2T_API_URL = (
58
+ "https://api-inference.huggingface.co/models/Sof22/image-caption-large-copy"
59
+ )
60
+ MONGO_CONN_STR = "mongodb+srv://sssingh:Topsycret1@cluster0.fcwxggj.mongodb.net/"
61
 
62
 
63
  app_config = AppConfig()