Spaces:
Runtime error
Runtime error
Commit
·
3ca5af2
1
Parent(s):
d4819df
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,23 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
|
4 |
-
filename = "test.zip"
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
from zipfile import ZipFile
|
2 |
|
3 |
+
import gradio as gr
|
|
|
4 |
|
5 |
+
|
6 |
+
def zip_to_json(file_obj):
|
7 |
+
files = []
|
8 |
+
with ZipFile(file_obj.name) as zfile:
|
9 |
+
for zinfo in zfile.infolist():
|
10 |
+
files.append(
|
11 |
+
{
|
12 |
+
"name": zinfo.filename,
|
13 |
+
"file_size": zinfo.file_size,
|
14 |
+
"compressed_size": zinfo.compress_size,
|
15 |
+
}
|
16 |
+
)
|
17 |
+
return files
|
18 |
+
|
19 |
+
|
20 |
+
demo = gr.Interface(zip_to_json, "file", "txt")
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
demo.launch()
|