Spaces:
Running
Running
import gradio as gr | |
# 定义两个简单的文本处理函数 | |
def process_aaa(text): | |
return text + 'aaa' | |
def process_bbb(text): | |
return text + 'bbb' | |
# 创建两个 Gradio 接口 | |
iface_aaa = gr.Interface( | |
fn=process_aaa, | |
inputs="text", | |
outputs="text", | |
title="API for /api/aaa", | |
description="输入文本并返回文本 + 'aaa'" | |
) | |
iface_bbb = gr.Interface( | |
fn=process_bbb, | |
inputs="text", | |
outputs="text", | |
title="API for /api/bbb", | |
description="输入文本并返回文本 + 'bbb'" | |
) | |
# 启动 Gradio 应用,包含两个子接口 | |
demo = gr.TabbedInterface( | |
[iface_aaa, iface_bbb], | |
["API /api/aaa", "API /api/bbb"] | |
) | |
if __name__ == "__main__": | |
demo.launch() | |