Spaces:
Runtime error
Runtime error
Create web.py
Browse files
web.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import datetime
|
3 |
+
import asyncio
|
4 |
+
|
5 |
+
def update_live_message():
|
6 |
+
""" νμ¬ μκ°κ³Ό 'live' λ©μμ§λ₯Ό λ°νν©λλ€. """
|
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():
|
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()
|