import gradio as gr import zipfile import os import base64 # Function to extract files from a zip file def extract_files(file): output_dir = "/path/to/extract/to" # replace with the path where you want to extract the files with zipfile.ZipFile(file.name, 'r') as zip_ref: zip_ref.extractall(output_dir) extracted_files = zip_ref.namelist() # Generate a downloadable link for each extracted file links = [] for filename in extracted_files: file_path = os.path.join(output_dir, filename) with open(file_path, "rb") as file: bytes = file.read() b64 = base64.b64encode(bytes).decode() href = f'Download {filename}' links.append(href) return "
".join(links) iface = gr.Interface(fn=extract_files, inputs="file", outputs="html", title="Zip File Extractor") iface.launch()