seawolf2357 commited on
Commit
4335c02
ยท
verified ยท
1 Parent(s): c677a73

Update web.py

Browse files
Files changed (1) hide show
  1. web.py +6 -5
web.py CHANGED
@@ -7,11 +7,12 @@ def update_live_message():
7
  current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
8
  return f"{current_time} - live"
9
 
10
- async def periodic_update(interface, interval=60):
11
  """ ์ฃผ์–ด์ง„ ์ธํ„ฐํŽ˜์ด์Šค์— 1๋ถ„ ๊ฐ„๊ฒฉ์œผ๋กœ ์—…๋ฐ์ดํŠธ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. """
12
  while True:
13
  live_message = update_live_message()
14
- interface.update(live_message)
 
15
  await asyncio.sleep(interval)
16
 
17
  def run_gradio():
@@ -24,10 +25,10 @@ def run_gradio():
24
  gr.Markdown("## Live Server Output")
25
  live_block
26
 
27
- demo.launch(server_name="0.0.0.0", server_port=7860, inbrowser=True)
28
 
29
  # ๋น„๋™๊ธฐ ์—…๋ฐ์ดํŠธ ์ž‘์—… ์‹œ์ž‘
30
- asyncio.run(periodic_update(live_block))
31
 
32
  if __name__ == "__main__":
33
- run_gradio()
 
7
  current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
8
  return f"{current_time} - live"
9
 
10
+ async def periodic_update(live_block, interval=60):
11
  """ ์ฃผ์–ด์ง„ ์ธํ„ฐํŽ˜์ด์Šค์— 1๋ถ„ ๊ฐ„๊ฒฉ์œผ๋กœ ์—…๋ฐ์ดํŠธ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. """
12
  while True:
13
  live_message = update_live_message()
14
+ live_block.value = live_message
15
+ await live_block.update()
16
  await asyncio.sleep(interval)
17
 
18
  def run_gradio():
 
25
  gr.Markdown("## Live Server Output")
26
  live_block
27
 
28
+ demo.launch(server_name="0.0.0.0", server_port=7860, inbrowser=True, start_server=True)
29
 
30
  # ๋น„๋™๊ธฐ ์—…๋ฐ์ดํŠธ ์ž‘์—… ์‹œ์ž‘
31
+ asyncio.create_task(periodic_update(live_block))
32
 
33
  if __name__ == "__main__":
34
+ run_gradio()