改为遍历配置文件

This commit is contained in:
mark.tian
2025-12-09 15:59:58 +08:00
parent d10c403ddc
commit f91c540bde
2 changed files with 22 additions and 80 deletions

View File

@@ -2,64 +2,6 @@
# API配置
API_CONFIG = {
# 主要API接口
'main_api': {
'url': 'https://jsonplaceholder.typicode.com/posts',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'User-Agent': 'Celery-Task/1.0'
},
'timeout': 30,
'body': {
'title': '每日定时任务',
'body': '这是通过配置文件设置的请求体数据',
'userId': 1
}
},
# 备用API接口
'backup_api': {
'url': 'https://jsonplaceholder.typicode.com/comments',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'User-Agent': 'Celery-Task/1.0'
},
'timeout': 30,
'body': {
'name': '备用任务',
'email': 'backup@example.com',
'body': '这是备用API的请求体'
}
},
# 健康检查API
'health_check': {
'url': 'https://jsonplaceholder.typicode.com/posts/1',
'method': 'GET',
'headers': {
'User-Agent': 'Celery-Task/1.0'
},
'timeout': 10,
'body': {} # GET请求通常不需要body,但可以设置查询参数
},
# GET请求示例API
'get_api': {
'url': 'https://jsonplaceholder.typicode.com/posts',
'method': 'GET',
'headers': {
'User-Agent': 'Celery-Task/1.0'
},
'timeout': 30,
'body': {
'userId': 1, # 这将作为查询参数
'limit': 10
}
},
# PUT请求示例API
'put_api': {
'url': 'https://jsonplaceholder.typicode.com/posts/1',
'method': 'PUT',