Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,19 +9,13 @@ from flask import Flask
|
|
9 |
logging.basicConfig(level=logging.INFO,
|
10 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
11 |
|
12 |
-
API_ENDPOINT = "https://api.siliconflow.cn/
|
13 |
|
14 |
app = Flask(__name__)
|
15 |
|
16 |
def get_credit_summary(api_key):
|
17 |
"""
|
18 |
使用 API 密钥获取额度信息。
|
19 |
-
|
20 |
-
Args:
|
21 |
-
api_key: 用于访问 API 的密钥。
|
22 |
-
|
23 |
-
Returns:
|
24 |
-
包含额度信息的字典,如果请求失败则返回 None。
|
25 |
"""
|
26 |
headers = {
|
27 |
"Authorization": f"Bearer {api_key}",
|
@@ -65,7 +59,8 @@ def index():
|
|
65 |
return "<h1>Welcome to SiliconFlow</h1>"
|
66 |
|
67 |
if __name__ == '__main__':
|
68 |
-
|
|
|
69 |
|
70 |
# 启动调度器
|
71 |
scheduler.start()
|
@@ -74,5 +69,5 @@ if __name__ == '__main__':
|
|
74 |
load_keys()
|
75 |
logging.info("首次加载 keys 已手动触发执行")
|
76 |
|
77 |
-
# 启动 Flask 应用,监听所有 IP 的
|
78 |
-
app.run(debug=False, host='0.0.0.0', port=
|
|
|
9 |
logging.basicConfig(level=logging.INFO,
|
10 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
11 |
|
12 |
+
API_ENDPOINT = "https://api.siliconflow.cn/dashboard/billing/usage"
|
13 |
|
14 |
app = Flask(__name__)
|
15 |
|
16 |
def get_credit_summary(api_key):
|
17 |
"""
|
18 |
使用 API 密钥获取额度信息。
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
"""
|
20 |
headers = {
|
21 |
"Authorization": f"Bearer {api_key}",
|
|
|
59 |
return "<h1>Welcome to SiliconFlow</h1>"
|
60 |
|
61 |
if __name__ == '__main__':
|
62 |
+
# 打印所有环境变量,方便调试
|
63 |
+
logging.info(f"环境变量:{os.environ}")
|
64 |
|
65 |
# 启动调度器
|
66 |
scheduler.start()
|
|
|
69 |
load_keys()
|
70 |
logging.info("首次加载 keys 已手动触发执行")
|
71 |
|
72 |
+
# 启动 Flask 应用,监听所有 IP 的 7860 端口(Hugging Face Space 默认端口)
|
73 |
+
app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|