adafruit_requests
¶
A requests-like library for web interfacing
Author(s): ladyada, Paul Sokolovsky, Scott Shawcroft
Implementation Notes¶
Adapted from https://github.com/micropython/micropython-lib/tree/master/urequests
micropython-lib consists of multiple modules from different sources and authors. Each module comes under its own licensing terms. Short name of a license can be found in a file within a module directory (usually metadata.txt or setup.py). Complete text of each license used is provided at https://github.com/micropython/micropython-lib/blob/master/LICENSE
author=’Paul Sokolovsky’ license=’MIT’
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Connection Manager library: https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager
- exception adafruit_requests.OutOfRetries¶
Raised when requests has retried to make a request unsuccessfully.
- class adafruit_requests.Response(sock: LegacyCircuitPythonSocketType | CircuitPythonSocketType | StandardPythonSocketType, session: Session)¶
The response from a request, contains all the headers/content
- property headers: Dict[str, str]¶
The response headers. Does not include headers from the trailer until the content has been read.
- class adafruit_requests.Session(socket_pool: module, ssl_context: SSLContext | _FakeSSLContext | None = None, session_id: str | None = None)¶
HTTP session that shares sockets and ssl context.
- request(method: str, url: str, data: Any | None = None, json: Any | None = None, headers: Dict[str, str] | None = None, stream: bool = False, timeout: float = 60, allow_redirects: bool = True) Response ¶
Perform an HTTP request to the given url which we will parse to determine whether to use SSL (’https://’) or not. We can also send some provided ‘data’ or a json dictionary which we will stringify. ‘headers’ is optional HTTP headers sent along. ‘stream’ will determine if we buffer everything, or whether to only read only when requested