更新mixiot库,支持图片编码
This commit is contained in:
@@ -30,6 +30,15 @@ def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
|||||||
print('\nnetwork config:', wlan.ifconfig())
|
print('\nnetwork config:', wlan.ifconfig())
|
||||||
return wlan
|
return wlan
|
||||||
|
|
||||||
|
def image_base64(path="mixly.jpg"):
|
||||||
|
from base64 import b64encode
|
||||||
|
if isinstance(path, str):
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
_data = f.read()
|
||||||
|
return 'data:image/{};base64,'.format(path.split('.')[-1]).encode() + b64encode(_data)
|
||||||
|
else:
|
||||||
|
return b'data:image/jpg;base64,' + b64encode(path)
|
||||||
|
|
||||||
def ntp(url='mixio.mixly.cn'):
|
def ntp(url='mixio.mixly.cn'):
|
||||||
import urequests
|
import urequests
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user