File size: 1,092 Bytes
9dbbaf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
import os
import zipfile
import base64

# Function to generate a downloadable link
def create_download_link(file_path):
    with open(file_path, "rb") as file:
        bytes = file.read()
        b64 = base64.b64encode(bytes).decode()
        href = f'<a href="data:file/octet-stream;base64,{b64}" download={os.path.basename(file_path)}>Download {os.path.basename(file_path)}</a>'
        return href

# Streamlit app
def app():
    uploaded_file = st.file_uploader("Choose a zip file", type="zip")

    if uploaded_file is not None:
        with zipfile.ZipFile(uploaded_file, 'r') as zip_ref:
            zip_ref.extractall("/path/to/extract/to")  # replace with the path where you want to extract the files

            st.success("Files extracted!")

            for filename in zip_ref.namelist():
                file_path = os.path.join("/path/to/extract/to", filename)  # replace with the path where you extracted the files
                st.markdown(create_download_link(file_path), unsafe_allow_html=True)

# Run the app
if __name__ == "__main__":
    app()