Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -132,6 +132,21 @@ def create_ui():
|
|
132 |
.space-row {margin-bottom: 5px !important;}
|
133 |
"""
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
136 |
gr.Markdown("# 300: HuggingFace Most Liked Spaces")
|
137 |
|
@@ -147,11 +162,11 @@ def create_ui():
|
|
147 |
|
148 |
with gr.Column(scale=1):
|
149 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=20)
|
150 |
-
url_state = gr.
|
151 |
-
last_url_state = gr.
|
152 |
screenshot_output = gr.Image(type="pil", label="Live 화면", height=360, width=600)
|
153 |
app_py_content = gr.Code(language="python", label="메인 소스코드")
|
154 |
-
|
155 |
|
156 |
for _, button, space in space_rows:
|
157 |
button.click(
|
@@ -160,16 +175,13 @@ def create_ui():
|
|
160 |
outputs=[info_output, app_py_content, url_state]
|
161 |
)
|
162 |
|
163 |
-
|
164 |
-
return (x + 1) % 1000000
|
165 |
-
|
166 |
-
update_trigger.change(
|
167 |
update_screenshot,
|
168 |
inputs=[url_state, last_url_state],
|
169 |
outputs=[screenshot_output, last_url_state]
|
170 |
)
|
171 |
|
172 |
-
|
173 |
|
174 |
return demo
|
175 |
|
|
|
132 |
.space-row {margin-bottom: 5px !important;}
|
133 |
"""
|
134 |
|
135 |
+
js = """
|
136 |
+
function updateScreenshot() {
|
137 |
+
const urlState = document.querySelector('#url_state textarea');
|
138 |
+
const lastUrlState = document.querySelector('#last_url_state textarea');
|
139 |
+
if (urlState && lastUrlState && urlState.value !== lastUrlState.value) {
|
140 |
+
const updateButton = document.querySelector('#update_screenshot_button');
|
141 |
+
if (updateButton) {
|
142 |
+
updateButton.click();
|
143 |
+
}
|
144 |
+
}
|
145 |
+
setTimeout(updateScreenshot, 5000);
|
146 |
+
}
|
147 |
+
setTimeout(updateScreenshot, 5000);
|
148 |
+
"""
|
149 |
+
|
150 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
151 |
gr.Markdown("# 300: HuggingFace Most Liked Spaces")
|
152 |
|
|
|
162 |
|
163 |
with gr.Column(scale=1):
|
164 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=20)
|
165 |
+
url_state = gr.Textbox(visible=False, elem_id="url_state")
|
166 |
+
last_url_state = gr.Textbox(visible=False, elem_id="last_url_state")
|
167 |
screenshot_output = gr.Image(type="pil", label="Live 화면", height=360, width=600)
|
168 |
app_py_content = gr.Code(language="python", label="메인 소스코드")
|
169 |
+
update_screenshot_button = gr.Button("Update Screenshot", visible=False, elem_id="update_screenshot_button")
|
170 |
|
171 |
for _, button, space in space_rows:
|
172 |
button.click(
|
|
|
175 |
outputs=[info_output, app_py_content, url_state]
|
176 |
)
|
177 |
|
178 |
+
update_screenshot_button.click(
|
|
|
|
|
|
|
179 |
update_screenshot,
|
180 |
inputs=[url_state, last_url_state],
|
181 |
outputs=[screenshot_output, last_url_state]
|
182 |
)
|
183 |
|
184 |
+
demo.load(None, None, None, _js=js)
|
185 |
|
186 |
return demo
|
187 |
|