-
-
Notifications
You must be signed in to change notification settings - Fork 24
requests
The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser. HTTP was developed to facilitate hypertext and the World Wide Web.
requests module enables trasfering data between K210 MicroPython and the remote http server.
- GET, HEAD, POST, PUT, PATCH and DELETE methods are supported.
- Using secured http (SSL/TLS) is supported (with WiFi interface only).
- Flexible POST method supporting sending multipart data (from MicroPython dictionary) and Base-64 encoded data.
- Status, headers and response data are provided as a result
- Receiving response data into file is supported
All http methods returns the result in the form of 3-item tuple: (status, header, response).
status http operation result code
header string, http response headers
response bytearray, http response body
If response to file was requested, response will be the string "Saved to file '<file_name>', size=<file_size>".
Sends GET request to the server.
url string containing the server address and optional parameters.
file optional, string containing the file name to which to save the response
bufsize optional, size of the temporary buffer used during transfer; default: 1536
Returns the result tuple.
Sends HEAD request to the server.
url string containing the server address and optional parameters.
Returns the result tuple. Only the status and header are returned.
| Argument | Description |
|---|---|
url |
string containing the server address, IP or domain name can be used |
params |
POST request parametersparams can be string (only if multipart=False or dictionaryIf multipart is False and params are distionary, the parameters will be url-encodedValid dictionary value that can be sent are: string, int, float or buffer object |
file |
optional, file name to which to save the response to Default: not used |
multipart |
optional, if set to True sends the multipard data requestDefault: FalseIf multipart is False, data are sent as "Content-Type: application/x-www-form-urlencoded"If multipart is True, data are sent as "Content-Type: multipart/form-data"
|
base64 |
optional, if set to True sends the buffer object parameter from multipart parameters as base64 encodedDefault: False
|
bufsize |
optional, size of the temporary buffer used during transfer Default: 1536 |
- Maix-M1 schematic
- Maix-Bit schematic
- Maix-Go schematic
- Kendryte K210 datasheet
- RISC-V ISA Design
- RISC-V ISA Manual
- Forum
- MicroPython documentation
If you find this project useful, you can contribute by making a donation