|
|
@@ -1,27 +1,39 @@
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
import requests
|
|
|
|
|
|
-url = 'http://192.168.31.243:7745/api/image_data/data_list'
|
|
|
+# 基础 URL
|
|
|
+base_url = 'http://192.168.31.243:7745/api/cards/card_list'
|
|
|
+
|
|
|
+# 查询参数 (query parameters)
|
|
|
params = {
|
|
|
- 'start_id': 5,
|
|
|
- 'end_id': 9,
|
|
|
'skip': 0,
|
|
|
'limit': 100
|
|
|
}
|
|
|
+
|
|
|
+# 请求头 (headers)
|
|
|
headers = {
|
|
|
'accept': 'application/json'
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
try:
|
|
|
- response = requests.get(url, params=params, headers=headers)
|
|
|
+ # 发送 GET 请求
|
|
|
+ response = requests.get(base_url, params=params, headers=headers)
|
|
|
+
|
|
|
+ # 检查响应状态码
|
|
|
response.raise_for_status()
|
|
|
|
|
|
- # 打印响应内容
|
|
|
- print("Status Code:", response.status_code)
|
|
|
- print("Response JSON:", response.json()) # 如果响应是JSON格式
|
|
|
- # print("Response Text:", response.text) # 如果响应是纯文本
|
|
|
+ # 打印响应内容 (JSON格式)
|
|
|
+ data = response.json()
|
|
|
+ print("Success! Response Data:")
|
|
|
+ print(data)
|
|
|
+
|
|
|
+ # 打印状态码
|
|
|
+ print(f"Status Code: {response.status_code}")
|
|
|
|
|
|
-except requests.exceptions.RequestException as e:
|
|
|
- print(f"An error occurred: {e}")
|
|
|
+except requests.exceptions.HTTPError as errh:
|
|
|
+ print(f"Http Error: {errh}")
|
|
|
+except requests.exceptions.ConnectionError as errc:
|
|
|
+ print(f"Error Connecting: {errc}")
|
|
|
+except requests.exceptions.Timeout as errt:
|
|
|
+ print(f"Timeout Error: {errt}")
|
|
|
+except requests.exceptions.RequestException as err:
|
|
|
+ print(f"An Error Occurred: {err}")
|