Spaces:
Runtime error
Runtime error
Update web.py
Browse files
web.py
CHANGED
@@ -2,9 +2,12 @@ import gradio as gr
|
|
2 |
import datetime
|
3 |
import asyncio
|
4 |
import ssl
|
|
|
|
|
5 |
|
6 |
-
#
|
7 |
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
8 |
|
9 |
def update_live_message():
|
10 |
"""
|
@@ -13,36 +16,33 @@ def update_live_message():
|
|
13 |
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
14 |
return f"{current_time} - live"
|
15 |
|
16 |
-
async def periodic_update(interface, interval=60):
|
17 |
-
"""
|
18 |
-
์ฃผ์ด์ง ์ธํฐํ์ด์ค์ 1๋ถ ๊ฐ๊ฒฉ์ผ๋ก ์
๋ฐ์ดํธ๋ฅผ ์คํํฉ๋๋ค.
|
19 |
-
"""
|
20 |
-
while True:
|
21 |
-
live_message = update_live_message()
|
22 |
-
interface.update(live_message)
|
23 |
-
await asyncio.sleep(interval)
|
24 |
-
|
25 |
def run_gradio():
|
26 |
"""
|
27 |
Gradio ์น ์ธํฐํ์ด์ค๋ฅผ ์ค์ ํ๊ณ ์คํํฉ๋๋ค.
|
28 |
"""
|
29 |
live_block = gr.Textbox(label="Live Output", value="Starting...", elem_id="live_output")
|
30 |
|
|
|
|
|
|
|
31 |
demo = gr.Blocks()
|
32 |
with demo:
|
33 |
gr.Markdown("## Live Server Output")
|
34 |
live_block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
# SSL
|
37 |
demo.launch(
|
38 |
server_name="0.0.0.0",
|
39 |
server_port=7860,
|
40 |
-
|
41 |
-
ssl_verify=False # Add this parameter
|
42 |
)
|
43 |
-
|
44 |
-
# ๋น๋๊ธฐ ์
๋ฐ์ดํธ ์์
์์
|
45 |
-
asyncio.run(periodic_update(live_block))
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
run_gradio()
|
|
|
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 |
"""
|
|
|
16 |
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
17 |
return f"{current_time} - live"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
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__":
|
48 |
run_gradio()
|