Skip to content

Commit 781a6ca

Browse files
authored
Merge pull request #1 from quecpython/main
quecpython_wiki_update
2 parents 5dcff85 + de08e00 commit 781a6ca

File tree

8 files changed

+4823
-1000
lines changed

8 files changed

+4823
-1000
lines changed

_media/favicon.ico

1.33 MB
Binary file not shown.

en-us/api/QuecPythonClasslib.md

Lines changed: 2063 additions & 249 deletions
Large diffs are not rendered by default.

en-us/api/QuecPythonThirdlib.md

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,15 @@ Send the POST request
598598
| decode | bool | (Optional)True decode the response content and return the str type. False turn off decoding and return bytes type. Default: True. (It is only used with response content). | |
599599
| sizeof | int | (Optional. Read the data in the buffer. Default: 255. Unit: byte. The larger the value, the faster the reading speeding. ( It is recommended to 255-4096 bytes because there may be the possibility of data loss if data setting is too large.) | |
600600

601+
* Content-Type explanation:
602+
603+
When using the POST method to submit data, the submitted data mainly has the following four forms:
604+
605+
- application/x-www-form-urlencoded:The form data is encoded in key/value format and sent to the server (the default format of the submitted data in the form)
606+
- multipart/form-data : When you need to upload files in the form, you need to use this format
607+
- application/json: JSON data format
608+
- application/octet-stream :Binary stream data (such as common file downloads)
609+
601610
* Example
602611

603612
```python
@@ -635,6 +644,40 @@ if __name__ == '__main__':
635644
http_log.info('Network connection failed! stagecode = {}, subcode = {}'.format(stagecode, subcode))
636645
```
637646

647+
##### File Upload
648+
649+
> **request.post(url, files, headers)**
650+
651+
Use the POST method to upload files to FTP. Currently, only uploads in the form of "multipart/form-data" are supported, and the default headers are "multipart/form-data".
652+
653+
* Parameter
654+
655+
| Parameter | Type | Description |
656+
| --------- | ------ | ------------------------------------------------------------ |
657+
| url | string | Service address |
658+
| files | dict | The dict type parameter must contain "filepath (device file path)" and "filename (file name)" |
659+
| headers | dict | (Optional parameter) The request header, the default is None, and the default Content-Type is "multipart/form-data" when uploading files. Currently, only "multipart/form-data" is supported. |
660+
661+
* Example
662+
663+
```python
664+
import request
665+
666+
url = '' # FTP service address, you need to enter an existing file path, for example: http://upload.file.com/folder
667+
files = {"filepath":"usr/upload.json", "filename":"upload.json"}
668+
669+
response = request.post(url, files=files)
670+
671+
'''
672+
You can also manually pass in headers, but currently upload files only support "multipart/form-data", the example is as follows:
673+
674+
header = {'Content-Type': 'multipart/form-data', 'charset': 'UTF-8'}
675+
response = post(url, files=files, headers=header)
676+
print(response.status_code)
677+
'''
678+
print(response.status_code) # status code
679+
```
680+
638681
##### Send PUT Request
639682

640683
> **request.put(url, data, headers,decode,sizeof)**
@@ -694,8 +737,6 @@ print(response.headers)
694737
| response.text | Returns the text content of the response in Unicode. |
695738
| response.json() | Returns the JSON encoded content of the response and converts it to dict type. |
696739

697-
698-
699740
**Request example**
700741

701742
```python
@@ -716,17 +757,31 @@ checknet = checkNet.CheckNetwork(PROJECT_NAME, PROJECT_VERSION)
716757
# Set the log output level
717758
log.basicConfig(level=log.INFO)
718759
http_log = log.getLogger("HTTP SSL")
719-
# HTTP(s) request
760+
# https request
720761
url = "https://myssl.com"
721762

722763
if __name__ == '__main__':
723764
stagecode, subcode = checknet.wait_network_connected(30)
724765
if stagecode == 3 and subcode == 1:
725766
http_log.info('Network connection successful!')
726-
727-
response = request.get(url) # Support SSl
728-
for i in response.text:
767+
'''
768+
PS:
769+
1.After using the returned response object to read the data once in text/content/json() etc., it cannot be read again
770+
2.The response.text and response.content methods return an iterator object (Iterable: All elements that can be traversed by a for loop can be called an iterable object), because the content returned by the request is considered too So we use the method of returning iterator to deal with, you can use the for loop to traverse the returned results, the example is as follows
771+
'''
772+
# response.text
773+
response = request.get(url) # Support ssl
774+
for i in response.text: # response.content is an iterator object
775+
print(i)
776+
# response.content
777+
response = request.get(url)
778+
for i in response.content: # response.content is an iterator object
729779
print(i)
780+
# response.json
781+
url = "http://httpbin.org/post"
782+
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
783+
response = request.post(url, data=ujson.dumps(data)) # Send HTTP POST request
784+
print(response.json())
730785
else:
731786
http_log.info('Network connection failed! stagecode = {}, subcode = {}'.format(stagecode, subcode))
732787
```

static/css/main.css

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.sidebar {
2-
background-color: rgb(245, 247, 250);
2+
background-color: #f8f8f8;
33
}
44
.sidebar-toggle{
55
background-color: rgba(245, 247, 250, 0);
@@ -17,4 +17,106 @@ input{
1717
-webkit-animation: neon2 1.5s ease-in-out infinite alternate;
1818
-moz-animation: neon2 1.5s ease-in-out infinite alternate;
1919
animation: neon2 1.5s ease-in-out infinite alternate;
20-
}
20+
}
21+
22+
.sidebar ul li > ul li > a{
23+
padding-left: 5px;
24+
border-left: 2px solid rgba(164, 166, 168, 0.3);
25+
}
26+
27+
28+
.sidebar ul li.active > a{
29+
border-left: 4px solid;
30+
color: var(--theme-color,#42b983) !important;
31+
border-right: 0px solid !important;
32+
background-color: rgba(255, 163, 163, 0.1);
33+
text-indent: 5px;
34+
}
35+
36+
.markdown-section h1 {
37+
padding-top: 70px;
38+
}
39+
40+
.markdown-section h2 {
41+
padding-top: 60px;
42+
}
43+
44+
.markdown-section h3 {
45+
padding-top: 50px;
46+
}
47+
48+
.markdown-section h4 {
49+
padding-top: 40px;
50+
}
51+
52+
.markdown-section h5 {
53+
padding-top: 30px;
54+
margin-bottom: 0rem !important;
55+
}
56+
57+
.markdown-section blockquote{
58+
margin-top: 0rem !important;
59+
margin-bottom: 0rem !important;
60+
margin-left: 2rem !important;
61+
background-color: #f8f8f8;
62+
}
63+
64+
.markdown-section code.lang-python, .markdown-section pre{
65+
background-color: #333 !important;
66+
border-radius: 9px;
67+
68+
}
69+
70+
.markdown-section code.lang-c, .markdown-section pre{
71+
background-color: #333 !important;
72+
border-radius: 9px;
73+
74+
}
75+
76+
.markdown-section code.lang-, .markdown-section pre{
77+
background-color: #333 !important;
78+
border-radius: 9px;
79+
80+
}
81+
82+
.docsify-copy-code-button:focus, pre:hover .docsify-copy-code-button{
83+
border-radius: 9px;
84+
opacity: 0.8 !important;
85+
margin-top: 0.2rem;
86+
margin-right: 0.2rem;
87+
}
88+
89+
.token.punctuation{
90+
color:#B0E0E6;
91+
}
92+
.lang-python{
93+
color:white !important;
94+
}
95+
.lang-c{
96+
color:white !important;
97+
}
98+
.lang-{
99+
color:white !important;
100+
}
101+
102+
body.close .sidebar-toggle {
103+
background-color: rgba(0, 0, 0, 0);
104+
transition: background-color 1s;
105+
width: 284px;
106+
padding: 10px;
107+
}
108+
109+
thead > tr{
110+
background-color: #dc143c;
111+
border: 2px solid #dc143c;
112+
color: white;
113+
line-height: 1.8rem;
114+
}
115+
116+
.github-corner{
117+
opacity: 0.5 !important;
118+
}
119+
120+
.github-corner:hover{
121+
opacity: 1 !important;
122+
}

0 commit comments

Comments
 (0)