File size: 415 Bytes
4dc254d
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
# Public Space:frontend.py
import os, requests, gradio as gr
API_URL = os.environ["BACKEND_URL"]          # 在 Space Secrets 里配置
API_TOKEN = os.environ["HF_TOKEN"]           # 也放 Secrets

def run(x):
    r = requests.post(API_URL, json={"input": x},
                      headers={"Authorization": f"Bearer {API_TOKEN}"})
    return r.json()["result"]

gr.Interface(run, "textbox", "textbox").launch()