BuckLakeAI / app.py
parkerjj's picture
Change to Docker
7e2a649
raw
history blame
802 Bytes
import gradio as gr
# 定义处理函数
def api_aaa(text):
return text + 'aaa'
def api_bbb(text):
return text + 'bbb'
# 创建两个独立的接口,分别对应两个功能
iface_aaa = gr.Interface(
fn=api_aaa,
inputs="text",
outputs="text",
description="API endpoint for appending 'aaa' to text"
)
iface_bbb = gr.Interface(
fn=api_bbb,
inputs="text",
outputs="text",
description="API endpoint for appending 'bbb' to text"
)
# 组合成 Blocks 页面
with gr.Blocks() as demo:
gr.Markdown("# 模拟 API 接口")
with gr.Tab("API /api/aaa"):
iface_aaa.render()
with gr.Tab("API /api/bbb"):
iface_bbb.render()
# 启动 Gradio 应用并启用 API 访问
if __name__ == "__main__":
demo.launch(enable_api=True)