更新mixiot库,支持图片编码

This commit is contained in:
dahanzimin
2025-06-13 17:38:52 +08:00
parent 107bd0c978
commit a7216cfcc7

View File

@@ -30,6 +30,15 @@ def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
print('\nnetwork config:', wlan.ifconfig())
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'):
import urequests
try: