本站改版新增arduino频道
支持大多数标准 HTTP 请求以及发送和接收分块数据
uHTTP
uHTTP是一个Micropython http request module。该模块支持大多数标准 HTTP 请求以及发送和接收分块数据等功能。
安装
将 uhttp 放在运行 Micropython 的微控制器上,并将其与 main.py 或 Micropython PATH 上的其他库目录放在一起。该模块现在应该可供导入。
用法
from uhttp import requests
url = 'http://someurl.com/'
# GET request
r = requests.get(url)
print(r.status_code)
print(r.text)
print(r.json)
# GET request which will save the body of the response to data.json
r = requests.get(url , save_to_file='data.json')
# POST request that sends the file 'data.json'
r = requests.post(url , file='data.json')
# POST request that sends the file 'my-image.png'
r = requests.post(url , file='my-image.png')
# POST request that will send data:dict as application/x-www-form-urlencoded
r = requests.post(url , data={'data':'my_data'})
# POST request that will send data:dict as application/json
r = requests.post(url , json={'data':'my_data'})
# POST request that will send empty body
r = requests.post(url)
# POST request with custom_headers
r = requests.post(url, custom_headers={"Authorization" : "Bearer myToken12355"})
# POST request that will send file in chunks
r = requests.post(url, file='my-image.png', chunked=True, chunk_size=128)
# Looking through the test directory will provide further insight into how the module functions.库地址:https://github.com/ksuaning-au/micropython-http
Copyright © 2014 ESP56.com All Rights Reserved  
晋ICP备14006235号-22 晋公网安备14108102001165号    
执行时间: 0.0095210075378418 seconds