Team Ai
Apppublic

fantaxy/kai-llm-code

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
web.py34 linesDownload Raw Back to root
1import gradio as gr2import datetime3import asyncio4 5def 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 10async 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 17def 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_block26    27    demo.launch(server_name="0.0.0.0", server_port=7860, inbrowser=True)28 29    # 비동기 업데이트 작업 시작30    asyncio.run(periodic_update(live_block))31 32if __name__ == "__main__":33    run_gradio()34