Skip to content

Commit 68583dc

Browse files
committed
Support MicroPython 1.21+ only
zlib module is now replaced by deflate module
1 parent e5ed72c commit 68583dc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import deflate
12
import gc
3+
import io
24
import json
35
import machine
46
import time
57
import uasyncio
6-
import zlib
78

89
from nanoweb.nanoweb import Nanoweb
910

1011
import wifi
1112
from tepra import Tepra, new_logger
1213
from typ1ng import Optional, Tuple
1314

14-
__version__ = '1.0.0'
15+
__version__ = '2.0.0'
1516

1617

1718
class Print:
@@ -162,7 +163,8 @@ async def handle_prints(req):
162163

163164
zl = await req.read(int(content_len))
164165
log('read from request body: {} bytes', len(zl))
165-
body = zlib.decompress(zl)
166+
with deflate.DeflateIO(io.BytesIO(zl), deflate.ZLIB) as d:
167+
body = d.read()
166168
log('decompressed: {} bytes', len(body))
167169

168170
success, reason = t.print(body, depth)

0 commit comments

Comments
 (0)