import gradio as gr # 自定义HTML/CSS/JavaScript custom_html = """

动态更新界面示例

点击按钮来更新这里的内容
""" # Gradio函数 def update_content(): import datetime current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") return f"界面已更新,当前时间: {current_time}" # 创建Gradio界面 iface = gr.Interface( fn=update_content, inputs=[], outputs="text", title=None, description=None, article=None, layout="vertical" ) iface.launch(inline=False, share=True, html=custom_html)