Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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()
|