Commit
•
3165ac3
1
Parent(s):
9cd0b93
Updating js_func
Browse files
app.py
CHANGED
@@ -105,7 +105,19 @@ log files. I use gradio for `app` and map that to the open port of huggingface s
|
|
105 |
The only communication between `app` and `main` is the log file.
|
106 |
"""
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
with gr.Tab("Application"):
|
110 |
gr.Markdown(intro_md)
|
111 |
gr.Image(str(proj_dir / 'media' / 'reddit_scraper.drawio.png'), type='filepath')
|
@@ -115,13 +127,6 @@ with gr.Blocks() as ui:
|
|
115 |
gr.Markdown(how_to_md)
|
116 |
with gr.Tab("How does it work?"):
|
117 |
gr.Markdown(how_does_it_work_md)
|
118 |
-
ui.load(None,
|
119 |
-
js="""
|
120 |
-
() => {
|
121 |
-
document.body.classList.toggle('dark');
|
122 |
-
document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
|
123 |
-
}
|
124 |
-
""", )
|
125 |
|
126 |
app = WebhooksServer(ui=ui.queue(), webhook_secret=WEBHOOK_SECRET)
|
127 |
|
|
|
105 |
The only communication between `app` and `main` is the log file.
|
106 |
"""
|
107 |
|
108 |
+
js_func = """
|
109 |
+
function refresh() {
|
110 |
+
const url = new URL(window.location);
|
111 |
+
|
112 |
+
if (url.searchParams.get('__theme') !== 'dark') {
|
113 |
+
url.searchParams.set('__theme', 'dark');
|
114 |
+
window.location.href = url.href;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
"""
|
118 |
+
|
119 |
+
|
120 |
+
with gr.Blocks(js=js_func) as ui:
|
121 |
with gr.Tab("Application"):
|
122 |
gr.Markdown(intro_md)
|
123 |
gr.Image(str(proj_dir / 'media' / 'reddit_scraper.drawio.png'), type='filepath')
|
|
|
127 |
gr.Markdown(how_to_md)
|
128 |
with gr.Tab("How does it work?"):
|
129 |
gr.Markdown(how_does_it_work_md)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
app = WebhooksServer(ui=ui.queue(), webhook_secret=WEBHOOK_SECRET)
|
132 |
|