mirror of
https://github.com/yshtcn/ServerChanPush2TelegramBot.git
synced 2025-12-11 16:50:22 +08:00
- 增加测试用例
This commit is contained in:
parent
9f393f3bc9
commit
8662334695
6
Post_Test.bat
Normal file
6
Post_Test.bat
Normal file
@ -0,0 +1,6 @@
|
||||
title 测试post
|
||||
:start
|
||||
@cd /d %~dp0
|
||||
py Post_Test.py
|
||||
pause
|
||||
goto start
|
||||
31
Post_Test.py
Normal file
31
Post_Test.py
Normal 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()
|
||||
Loading…
x
Reference in New Issue
Block a user