From 86623346951ca04e93f8a4999bcb96946cf44df7 Mon Sep 17 00:00:00 2001 From: yshtcn Date: Fri, 8 Sep 2023 12:04:43 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Post_Test.bat | 6 ++++++ Post_Test.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Post_Test.bat create mode 100644 Post_Test.py diff --git a/Post_Test.bat b/Post_Test.bat new file mode 100644 index 0000000..9fb059b --- /dev/null +++ b/Post_Test.bat @@ -0,0 +1,6 @@ +title 测试post +:start +@cd /d %~dp0 +py Post_Test.py +pause +goto start \ No newline at end of file diff --git a/Post_Test.py b/Post_Test.py new file mode 100644 index 0000000..aa488d2 --- /dev/null +++ b/Post_Test.py @@ -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()