- 增加测试用例

This commit is contained in:
yshtcn 2023-09-08 12:04:43 +08:00
parent 9f393f3bc9
commit 8662334695
2 changed files with 37 additions and 0 deletions

6
Post_Test.bat Normal file
View File

@ -0,0 +1,6 @@
title 测试post
:start
@cd /d %~dp0
py Post_Test.py
pause
goto start

31
Post_Test.py Normal file
View File

@ -0,0 +1,31 @@
import requests
def send_post_request():
url = "http://localhost:5000" # 请替换为实际API端点
# 构建表单数据
payload = {
"bot_id": "",
"chat_id": "",
"title": "Test Title",
"desp": "Test Description---Test Description",
"url": "https://example.com"
}
# 发送POST请求
response = requests.post(url, data=payload)
# 输出状态码
print(f"Status Code: {response.status_code}")
# 输出响应文本
print(f"Response Text: {response.text}")
# 在尝试解析JSON之前先检查响应是否包含JSON
try:
print(f"Response Data: {response.json()}")
except:
print("Failed to parse JSON from response.")
if __name__ == "__main__":
send_post_request()