Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -132,21 +132,6 @@ def create_ui():
|
|
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,27 +147,22 @@ def create_ui():
|
|
162 |
|
163 |
with gr.Column(scale=1):
|
164 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=20)
|
165 |
-
url_state = gr.
|
166 |
-
last_url_state = gr.
|
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(
|
173 |
lambda s=space: on_select(s),
|
174 |
inputs=[],
|
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 |
|
188 |
except Exception as e:
|
|
|
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 |
|
148 |
with gr.Column(scale=1):
|
149 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=20)
|
150 |
+
url_state = gr.State("")
|
151 |
+
last_url_state = gr.State("")
|
152 |
screenshot_output = gr.Image(type="pil", label="Live 화면", height=360, width=600)
|
153 |
app_py_content = gr.Code(language="python", label="메인 소스코드")
|
|
|
154 |
|
155 |
for _, button, space in space_rows:
|
156 |
button.click(
|
157 |
lambda s=space: on_select(s),
|
158 |
inputs=[],
|
159 |
outputs=[info_output, app_py_content, url_state]
|
160 |
+
).then(
|
161 |
+
update_screenshot,
|
162 |
+
inputs=[url_state, last_url_state],
|
163 |
+
outputs=[screenshot_output, last_url_state]
|
164 |
)
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
return demo
|
167 |
|
168 |
except Exception as e:
|