Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -432,20 +432,27 @@ def generate_stream_response(response, model, prompt_tokens):
|
|
| 432 |
def get_auth_credentials():
|
| 433 |
"""从API获取认证凭据"""
|
| 434 |
try:
|
|
|
|
| 435 |
headers = {
|
| 436 |
'accept': '*/*',
|
| 437 |
'accept-language': 'zh-CN,zh;q=0.9',
|
| 438 |
'user-agent': _USER_AGENT,
|
| 439 |
'x-password': '321'
|
| 440 |
}
|
| 441 |
-
response =
|
| 442 |
if response.status_code == 200:
|
| 443 |
data = response.json()
|
| 444 |
if data.get('status') == 'success' and data.get('content'):
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
return []
|
| 450 |
except Exception as e:
|
| 451 |
logger.error(f"Error getting credentials from API: {e}")
|
|
|
|
| 432 |
def get_auth_credentials():
|
| 433 |
"""从API获取认证凭据"""
|
| 434 |
try:
|
| 435 |
+
session = create_custom_session()
|
| 436 |
headers = {
|
| 437 |
'accept': '*/*',
|
| 438 |
'accept-language': 'zh-CN,zh;q=0.9',
|
| 439 |
'user-agent': _USER_AGENT,
|
| 440 |
'x-password': '321'
|
| 441 |
}
|
| 442 |
+
response = session.get(_PASTE_API_URL, headers=headers)
|
| 443 |
if response.status_code == 200:
|
| 444 |
data = response.json()
|
| 445 |
if data.get('status') == 'success' and data.get('content'):
|
| 446 |
+
content = data['content']
|
| 447 |
+
if '|' in content: # 确保内容包含分隔符
|
| 448 |
+
email, password = content.split('|')
|
| 449 |
+
return [(email.strip(), password.strip())]
|
| 450 |
+
else:
|
| 451 |
+
logger.error(f"Invalid content format: {content}")
|
| 452 |
+
else:
|
| 453 |
+
logger.error(f"Invalid API response: {data}")
|
| 454 |
+
else:
|
| 455 |
+
logger.error(f"API request failed with status code: {response.status_code}")
|
| 456 |
return []
|
| 457 |
except Exception as e:
|
| 458 |
logger.error(f"Error getting credentials from API: {e}")
|