offerpk3 commited on
Commit
b3c7d74
·
verified ·
1 Parent(s): 088fb3b

Update helpers.py

Browse files
Files changed (1) hide show
  1. helpers.py +9 -8
helpers.py CHANGED
@@ -1,9 +1,10 @@
1
- import io, zipfile
 
2
 
3
- def save_as_zip(bundle):
4
- mem = io.BytesIO()
5
- z = zipfile.ZipFile(mem, "w")
6
- z.writestr("app_bundle.txt", bundle["full_code"])
7
- z.close()
8
- mem.seek(0)
9
- return mem.getvalue()
 
1
+ import zipfile
2
+ import io
3
 
4
+ def save_as_zip(bundle: dict) -> bytes:
5
+ zip_buffer = io.BytesIO()
6
+ with zipfile.ZipFile(zip_buffer, "w") as zipf:
7
+ for filename, content in bundle.get("files", {}).items():
8
+ zipf.writestr(filename, content)
9
+ zip_buffer.seek(0)
10
+ return zip_buffer.read()