sh2_util 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sh2_util/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+
2
+
@@ -0,0 +1 @@
1
+ from .col import add
sh2_util/col/col.py ADDED
@@ -0,0 +1,2 @@
1
+ def add(a,b):
2
+ return a+b+b
sh2_util/http.py ADDED
@@ -0,0 +1,59 @@
1
+ #!/Users/tuze/.pyenv/shims/python
2
+
3
+ import json
4
+
5
+ import requests
6
+ from colorama import Fore, Style, init
7
+
8
+ # 初始化 colorama
9
+ init(autoreset=True)
10
+
11
+ # 发送HTTP POST请求
12
+ def send_post_request(url, headers, data):
13
+ """ 发送 POST 请求并返回响应 """
14
+ print_request(url, headers, data)
15
+ response = requests.post(url, headers=headers, data=json.dumps(data))
16
+ print_response(response)
17
+ return response
18
+
19
+ # 打印响应
20
+ def print_response(response):
21
+ """ 打印请求的状态码、头部信息和响应体 """
22
+
23
+ # 获取 HTTP 协议版本
24
+ if response.raw.version == 10:
25
+ http_version = 'HTTP/1.0'
26
+ elif response.raw.version == 11:
27
+ http_version = 'HTTP/1.1'
28
+ elif response.raw.version == 20:
29
+ http_version = 'HTTP/2'
30
+ else:
31
+ http_version = 'Unknown'
32
+
33
+ # 打印状态码
34
+ if response.status_code == 200:
35
+ print(Fore.GREEN+f"响应Code\n{http_version} {response.status_code} {response.reason}\n")
36
+ else:
37
+ print(Fore.RED+f"{http_version} {response.status_code} {response.reason}\n")
38
+
39
+ print(Fore.CYAN+f"响应Headers\n{json.dumps(dict(response.headers), ensure_ascii=False,indent=4)}\n")
40
+
41
+ # 打印响应体
42
+ try:
43
+ data = json.dumps(response.json(), indent=4, ensure_ascii=False)
44
+ print(Fore.YELLOW+f"响应Body\n{data} \n")
45
+ except:
46
+ print(Fore.YELLOW+f"响应Body\n{response.text} \n")
47
+
48
+ # 打印请求
49
+ def print_request(url, headers, data):
50
+ """ 打印请求的状态码、头部信息和响应体 """
51
+ # 打印url
52
+ print(Fore.GREEN+f"请求URL\n{url}\n")
53
+
54
+
55
+ # 打印请求Headers
56
+ print(Fore.CYAN+f"请求Headers\n{json.dumps(headers, ensure_ascii=False,indent=4)}\n")
57
+
58
+ # 打印请求body
59
+ print(Fore.YELLOW+f"请求Body\n{json.dumps(data, ensure_ascii=False,indent=4)}\n")
@@ -0,0 +1,2 @@
1
+
2
+ from .str import *
sh2_util/str/str.py ADDED
@@ -0,0 +1,2 @@
1
+ def hello():
2
+ return "Hello, World!"
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: sh2_util
3
+ Version: 0.1.0
4
+ Summary: sh2 tool
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: colorama>=0.4.6
8
+ Requires-Dist: requests>=2.32.3
@@ -0,0 +1,10 @@
1
+ sh2_util/__init__.py,sha256=daEdpEyAJIa8b2VkCqSKcw8PaExcB6Qro80XNes_sHA,2
2
+ sh2_util/http.py,sha256=wvUoo943WfFOw5jw8YyZsgLcDinzYQb6BZctehXUiL0,1833
3
+ sh2_util/col/__init__.py,sha256=5hukC5IqKnTbEWoInVAtn9xkEUqe-DVZgfdY1WooeEQ,21
4
+ sh2_util/col/col.py,sha256=9tCTvXob1ZJw7mEZwLbhYC8sI3WNNPX_HOUvCd79Ohs,30
5
+ sh2_util/str/__init__.py,sha256=d2MdaPqrCydcnTgm_J6yiGsXKuJ-xhlNOEYrfu_CIu8,20
6
+ sh2_util/str/str.py,sha256=bsIntEpMkZGHbp61KVc1FhqX5eDNv9AidNj5EmqmOuA,39
7
+ sh2_util-0.1.0.dist-info/METADATA,sha256=EfKyj89RPrGcyVHythEhpvvjjFLHf4mvjR-vEjR3xL8,197
8
+ sh2_util-0.1.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
9
+ sh2_util-0.1.0.dist-info/top_level.txt,sha256=qUqIg690edBWT3baiExUNpouh3NsUF0MH6b5acH1m5w,9
10
+ sh2_util-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ sh2_util