kopia lustrzana https://github.com/micropython/micropython-lib
requests: Rename urequests to requests.
This module implements a subset of the Python requests module, and so it should have the same name. Added a backwards-compatibility wrapper to allow people to continue to use `import urequests`. This lives in micropython/urequests. Changed requests to be a package, so that we can implement extension packages in the future for optional functionality. Added a basic README.md to both. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>pull/702/head
rodzic
5004436164
commit
8513bfbe9d
|
@ -5,5 +5,9 @@ metadata(
|
|||
|
||||
require("mip")
|
||||
require("ntptime")
|
||||
require("urequests")
|
||||
require("requests")
|
||||
require("webrepl")
|
||||
|
||||
# Provide urequests (which just forwards to requests) for backwards
|
||||
# compatibility.
|
||||
require("urequests")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
metadata(version="0.2.0", description="On-device package installer for network-capable boards")
|
||||
|
||||
require("urequests")
|
||||
require("requests")
|
||||
|
||||
package("mip", opt=3)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# MicroPython package installer
|
||||
# MIT license; Copyright (c) 2022 Jim Mussared
|
||||
|
||||
import urequests as requests
|
||||
import requests
|
||||
import sys
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
## urequests compatibility
|
||||
|
||||
The MicroPython version of
|
||||
[requests](https://requests.readthedocs.io/en/latest/) was previously called
|
||||
`urequests` and a lot of existing code depends on being able to still
|
||||
import the module by that name.
|
||||
|
||||
This package provides a wrapper to allow this. Prefer to install and use the
|
||||
`requests` package instead.
|
|
@ -0,0 +1,5 @@
|
|||
metadata(version="0.8.0", pypi="requests")
|
||||
|
||||
require("requests")
|
||||
|
||||
module("urequests.py")
|
|
@ -0,0 +1,8 @@
|
|||
# This module provides a backwards-compatble import for `urequests`.
|
||||
# It lazy-loads from `requests` without duplicating its globals dict.
|
||||
|
||||
|
||||
def __getattr__(attr):
|
||||
import requests
|
||||
|
||||
return getattr(requests, attr)
|
|
@ -0,0 +1,16 @@
|
|||
## requests
|
||||
|
||||
This module provides a lightweight version of the Python
|
||||
[requests](https://requests.readthedocs.io/en/latest/) library.
|
||||
|
||||
It includes support for all HTTP verbs, https, json decoding of responses,
|
||||
redirects, basic authentication.
|
||||
|
||||
### Limitations
|
||||
|
||||
* Certificate validation is not currently supported.
|
||||
* A dictionary passed as post data will not do automatic JSON or
|
||||
multipart-form encoding of post data (this can be done manually).
|
||||
* Compressed requests/responses are not currently supported.
|
||||
* File upload is not supported.
|
||||
* Chunked encoding in responses is not supported.
|
|
@ -1,7 +1,4 @@
|
|||
try:
|
||||
import urequests as requests
|
||||
except ImportError:
|
||||
import requests
|
||||
import requests
|
||||
|
||||
r = requests.get("http://api.xively.com/")
|
||||
print(r)
|
|
@ -0,0 +1,3 @@
|
|||
metadata(version="0.8.0", pypi="requests")
|
||||
|
||||
package("requests")
|
|
@ -1,3 +0,0 @@
|
|||
metadata(version="0.7.0", pypi="requests")
|
||||
|
||||
module("urequests.py")
|
Ładowanie…
Reference in New Issue