Update app.py
Browse files
app.py
CHANGED
|
@@ -104,10 +104,10 @@ def on_select(space):
|
|
| 104 |
print(traceback.format_exc())
|
| 105 |
return f"μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}", "", ""
|
| 106 |
|
| 107 |
-
def update_screenshot(url):
|
| 108 |
-
if url:
|
| 109 |
-
return take_screenshot(url)
|
| 110 |
-
return None
|
| 111 |
|
| 112 |
def take_screenshot(url):
|
| 113 |
try:
|
|
@@ -146,7 +146,8 @@ def create_ui():
|
|
| 146 |
|
| 147 |
with gr.Column(scale=1):
|
| 148 |
info_output = gr.Textbox(label="Space μ 보 λ° μμ½", lines=20)
|
| 149 |
-
url_state = gr.
|
|
|
|
| 150 |
screenshot_output = gr.Image(type="pil", label="Live νλ©΄", height=360, width=600)
|
| 151 |
app_py_content = gr.Code(language="python", label="λ©μΈ μμ€μ½λ")
|
| 152 |
|
|
@@ -157,11 +158,11 @@ def create_ui():
|
|
| 157 |
outputs=[info_output, app_py_content, url_state]
|
| 158 |
)
|
| 159 |
|
| 160 |
-
|
| 161 |
-
update_screenshot,
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
)
|
| 166 |
|
| 167 |
return demo
|
|
|
|
| 104 |
print(traceback.format_exc())
|
| 105 |
return f"μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}", "", ""
|
| 106 |
|
| 107 |
+
def update_screenshot(url, last_url):
|
| 108 |
+
if url and url != last_url:
|
| 109 |
+
return take_screenshot(url), url
|
| 110 |
+
return None, last_url
|
| 111 |
|
| 112 |
def take_screenshot(url):
|
| 113 |
try:
|
|
|
|
| 146 |
|
| 147 |
with gr.Column(scale=1):
|
| 148 |
info_output = gr.Textbox(label="Space μ 보 λ° μμ½", lines=20)
|
| 149 |
+
url_state = gr.State("")
|
| 150 |
+
last_url_state = gr.State("")
|
| 151 |
screenshot_output = gr.Image(type="pil", label="Live νλ©΄", height=360, width=600)
|
| 152 |
app_py_content = gr.Code(language="python", label="λ©μΈ μμ€μ½λ")
|
| 153 |
|
|
|
|
| 158 |
outputs=[info_output, app_py_content, url_state]
|
| 159 |
)
|
| 160 |
|
| 161 |
+
demo.add_periodic_callback(
|
| 162 |
+
lambda: update_screenshot(url_state.value, last_url_state.value),
|
| 163 |
+
5,
|
| 164 |
+
inputs=[url_state, last_url_state],
|
| 165 |
+
outputs=[screenshot_output, last_url_state]
|
| 166 |
)
|
| 167 |
|
| 168 |
return demo
|