awacke1 commited on
Commit
9dbbaf1
·
1 Parent(s): 93c207c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import zipfile
4
+ import base64
5
+
6
+ # Function to generate a downloadable link
7
+ def create_download_link(file_path):
8
+ with open(file_path, "rb") as file:
9
+ bytes = file.read()
10
+ b64 = base64.b64encode(bytes).decode()
11
+ href = f'<a href="data:file/octet-stream;base64,{b64}" download={os.path.basename(file_path)}>Download {os.path.basename(file_path)}</a>'
12
+ return href
13
+
14
+ # Streamlit app
15
+ def app():
16
+ uploaded_file = st.file_uploader("Choose a zip file", type="zip")
17
+
18
+ if uploaded_file is not None:
19
+ with zipfile.ZipFile(uploaded_file, 'r') as zip_ref:
20
+ zip_ref.extractall("/path/to/extract/to") # replace with the path where you want to extract the files
21
+
22
+ st.success("Files extracted!")
23
+
24
+ for filename in zip_ref.namelist():
25
+ file_path = os.path.join("/path/to/extract/to", filename) # replace with the path where you extracted the files
26
+ st.markdown(create_download_link(file_path), unsafe_allow_html=True)
27
+
28
+ # Run the app
29
+ if __name__ == "__main__":
30
+ app()