Spaces:
Running
Running
feat; read env
Browse files
app.py
CHANGED
@@ -1,9 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import json
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
"""
|
9 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import json
|
4 |
+
import os
|
5 |
+
from dotenv import load_dotenv
|
6 |
|
7 |
+
# 加载.env文件中的环境变量
|
8 |
+
load_dotenv()
|
9 |
+
|
10 |
+
# 从环境变量中读取配置
|
11 |
+
API_URL = os.getenv("API_URL")
|
12 |
+
API_TOKEN = os.getenv("API_TOKEN")
|
13 |
+
|
14 |
+
# 验证必要的环境变量
|
15 |
+
if not API_URL or not API_TOKEN:
|
16 |
+
raise ValueError("请确保设置了环境变量 API_URL 和 API_TOKEN")
|
17 |
+
|
18 |
+
print(f"[INFO] 服务启动配置:")
|
19 |
+
print(f"[INFO] API_URL: {API_URL}")
|
20 |
+
print(f"[INFO] API_TOKEN: {API_TOKEN[:10]}...{API_TOKEN[-10:]}") # 只显示token的前10位和后10位
|
21 |
|
22 |
"""
|
23 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|