boardman7 commited on
Commit
4dc254d
·
verified ·
1 Parent(s): 63daba4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Public Space:frontend.py
2
+ import os, requests, gradio as gr
3
+ API_URL = os.environ["BACKEND_URL"] # 在 Space Secrets 里配置
4
+ API_TOKEN = os.environ["HF_TOKEN"] # 也放 Secrets
5
+
6
+ def run(x):
7
+ r = requests.post(API_URL, json={"input": x},
8
+ headers={"Authorization": f"Bearer {API_TOKEN}"})
9
+ return r.json()["result"]
10
+
11
+ gr.Interface(run, "textbox", "textbox").launch()