ginipick commited on
Commit
f78ba74
·
verified ·
1 Parent(s): 7e8c8ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -106,8 +106,9 @@ def on_select(space):
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:
@@ -150,6 +151,7 @@ def create_ui():
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
 
154
  for _, button, space in space_rows:
155
  button.click(
@@ -158,13 +160,17 @@ def create_ui():
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
169
 
170
  except Exception as e:
 
106
 
107
  def update_screenshot(url, last_url):
108
  if url and url != last_url:
109
+ screenshot = take_screenshot(url)
110
+ return screenshot, url
111
+ return gr.update(), last_url
112
 
113
  def take_screenshot(url):
114
  try:
 
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
+ update_trigger = gr.Number(value=0, visible=False)
155
 
156
  for _, button, space in space_rows:
157
  button.click(
 
160
  outputs=[info_output, app_py_content, url_state]
161
  )
162
 
163
+ def increment(x):
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
+ demo.load(increment, inputs=update_trigger, outputs=update_trigger, every=5)
173
+
174
  return demo
175
 
176
  except Exception as e: