File size: 466 Bytes
3a47676
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import time  # 模拟处理耗时

def process_api(input_text):
    # 这里编写实际的后端处理逻辑
    time.sleep(1)  # 模拟处理延迟
    return {
        "status": "success",
        "result": f"Processed: {input_text.upper()}",
        "timestamp": time.time()
    }

# 设置API格式为JSON
gr.Interface(
    fn=process_api,
    inputs="text",
    outputs="json",
    title="Backend API",
    allow_flagging="never"
).launch()