ginipick commited on
Commit
7d5dc03
ยท
verified ยท
1 Parent(s): a314289

Update web.py

Browse files
Files changed (1) hide show
  1. web.py +28 -23
web.py CHANGED
@@ -1,13 +1,6 @@
1
  import gradio as gr
2
  import datetime
3
- import asyncio
4
- import ssl
5
- import requests
6
- from urllib3.exceptions import InsecureRequestWarning
7
-
8
- # SSL ์ธ์ฆ์„œ ๊ฒ€์ฆ ์˜ค๋ฅ˜ ๋ฐฉ์ง€
9
- ssl._create_default_https_context = ssl._create_unverified_context
10
- requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
11
 
12
  def update_live_message():
13
  """
@@ -20,28 +13,40 @@ def run_gradio():
20
  """
21
  Gradio ์›น ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
22
  """
23
- live_block = gr.Textbox(label="Live Output", value="Starting...", elem_id="live_output")
24
-
25
- # ์ž๋™ ์—…๋ฐ์ดํŠธ ์ธํ„ฐ๋ฒŒ ์„ค์ • (์ดˆ ๋‹จ์œ„)
26
- update_interval = 60
27
-
28
- demo = gr.Blocks()
29
- with demo:
30
  gr.Markdown("## Live Server Output")
31
- live_block
32
 
33
- # ์ฃผ๊ธฐ์  ์—…๋ฐ์ดํŠธ๋ฅผ ์œ„ํ•œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์„ค์ •
34
- demo.load(
 
 
 
 
 
 
 
 
35
  fn=update_live_message,
36
- outputs=live_block,
37
- every=update_interval # ์„ค์ •ํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ ์ž๋™ ์—…๋ฐ์ดํŠธ
38
  )
 
 
 
 
 
 
 
 
 
39
 
40
- # SSL ๊ฒ€์ฆ ๋น„ํ™œ์„ฑํ™” ์˜ต์…˜ ์ถ”๊ฐ€
41
  demo.launch(
42
  server_name="0.0.0.0",
43
- server_port=7860,
44
- ssl_verify=False
 
45
  )
46
 
47
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  import datetime
3
+ import os
 
 
 
 
 
 
 
4
 
5
  def update_live_message():
6
  """
 
13
  """
14
  Gradio ์›น ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
15
  """
16
+ # ๋ธ”๋ก ID๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ์„ค์ •
17
+ with gr.Blocks(analytics_enabled=False) as demo:
 
 
 
 
 
18
  gr.Markdown("## Live Server Output")
 
19
 
20
+ # ๋ช…์‹œ์  ID ํ• ๋‹น
21
+ live_block = gr.Textbox(
22
+ label="Live Output",
23
+ value=update_live_message(),
24
+ elem_id="live_output"
25
+ )
26
+
27
+ # ์ฃผ๊ธฐ์  ์—…๋ฐ์ดํŠธ ๋ฒ„ํŠผ (์ž๋™ ์—…๋ฐ์ดํŠธ ๋Œ€์‹ )
28
+ refresh_btn = gr.Button("์ƒˆ๋กœ๊ณ ์นจ")
29
+ refresh_btn.click(
30
  fn=update_live_message,
31
+ inputs=None,
32
+ outputs=live_block
33
  )
34
+
35
+ # ์ˆ˜๋™์œผ๋กœ ์ผ์ • ๊ฐ„๊ฒฉ ์—…๋ฐ์ดํŠธ๋ฅผ ์œ„ํ•œ JavaScript ์ถ”๊ฐ€
36
+ gr.HTML("""
37
+ <script>
38
+ setInterval(function() {
39
+ document.querySelector("button").click();
40
+ }, 60000); // 60์ดˆ๋งˆ๋‹ค ์ƒˆ๋กœ๊ณ ์นจ
41
+ </script>
42
+ """)
43
 
44
+ # Gradio ์„œ๋ฒ„ ์„ค์ •
45
  demo.launch(
46
  server_name="0.0.0.0",
47
+ server_port=7860,
48
+ show_error=True, # ์˜ค๋ฅ˜ ํ‘œ์‹œ ํ™œ์„ฑํ™”
49
+ quiet=False # ๋กœ๊ทธ ํ‘œ์‹œ ํ™œ์„ฑํ™”
50
  )
51
 
52
  if __name__ == "__main__":