SUHHHH commited on
Commit
039160b
โ€ข
1 Parent(s): 092ea0c

Update web.py

Browse files
Files changed (1) hide show
  1. web.py +15 -12
web.py CHANGED
@@ -11,23 +11,26 @@ 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():
18
  """ Gradio ์›น ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. """
19
- live_block = gr.Textbox(label="Live Output", value="Starting...", elem_id="live_output")
20
-
21
- demo = gr.Blocks()
22
-
23
- with demo:
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()
 
11
  """ ์ฃผ์–ด์ง„ ์ธํ„ฐํŽ˜์ด์Šค์— 1๋ถ„ ๊ฐ„๊ฒฉ์œผ๋กœ ์—…๋ฐ์ดํŠธ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. """
12
  while True:
13
  live_message = update_live_message()
14
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์—…๋ฐ์ดํŠธ
15
+ interface(live_message)
16
  await asyncio.sleep(interval)
17
 
18
  def run_gradio():
19
  """ Gradio ์›น ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. """
20
+ with gr.Blocks() as demo:
21
+ live_output = gr.Textbox(label="Live Output", value="Starting...", elem_id="live_output", interactive=False)
22
+
23
+ async def live_update_task():
24
+ """ ๋น„๋™๊ธฐ ์ž‘์—… ์‹คํ–‰ """
25
+ while True:
26
+ current_time = update_live_message()
27
+ live_output.update(value=current_time)
28
+ await asyncio.sleep(60)
29
 
30
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰ ์‹œ ์ด๋ฒคํŠธ ๋ฃจํ”„์™€ ํ†ตํ•ฉ
31
+ demo.load(live_update_task)
32
+
33
+ demo.launch(server_name="0.0.0.0", server_port=7860, inbrowser=True)
34
 
35
  if __name__ == "__main__":
36
  run_gradio()