修复
This commit is contained in:
@@ -19,37 +19,47 @@ def get_emails_by_address(email_address, limit=10, unread_only=False, since=None
|
||||
返回:
|
||||
API响应的JSON数据
|
||||
"""
|
||||
base_url = "http://localhost:5000/api/emails/by-address"
|
||||
# 构建API URL
|
||||
api_url = f"http://74.48.75.19:5000/api/emails/by-address"
|
||||
|
||||
# 构建参数
|
||||
# 构建查询参数
|
||||
params = {
|
||||
'email_address': email_address,
|
||||
'limit': limit
|
||||
"email_address": email_address,
|
||||
"limit": limit
|
||||
}
|
||||
|
||||
# 添加可选参数
|
||||
if unread_only:
|
||||
params['unread_only'] = 'true'
|
||||
|
||||
params["unread_only"] = "true"
|
||||
if since:
|
||||
params['since'] = since
|
||||
params["since"] = since
|
||||
|
||||
# 打印请求信息
|
||||
print(f"请求URL: {api_url}")
|
||||
print(f"参数: {params}")
|
||||
|
||||
# 发送请求
|
||||
try:
|
||||
print(f"请求 URL: {base_url}?{'&'.join([f'{k}={v}' for k, v in params.items()])}")
|
||||
response = requests.get(base_url, params=params)
|
||||
# 发送API请求
|
||||
response = requests.get(api_url, params=params, timeout=15)
|
||||
|
||||
# 打印响应信息
|
||||
print(f"状态码: {response.status_code}")
|
||||
# 打印响应状态
|
||||
print(f"响应状态码: {response.status_code}")
|
||||
|
||||
# 返回JSON数据
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return data
|
||||
return response.json()
|
||||
else:
|
||||
print(f"请求失败: {response.text}")
|
||||
return None
|
||||
print(f"API请求失败: {response.text}")
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"请求失败: HTTP {response.status_code}"
|
||||
}
|
||||
except Exception as e:
|
||||
print(f"请求出错: {str(e)}")
|
||||
return None
|
||||
print(f"发生错误: {str(e)}")
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"发生异常: {str(e)}"
|
||||
}
|
||||
|
||||
def format_email_info(email):
|
||||
"""格式化邮件信息显示"""
|
||||
|
||||
Reference in New Issue
Block a user