import zipfile import gradio as gr import os def unzip_file(file): extract_path = "extracted_files" # Define a path to extract files os.makedirs(extract_path, exist_ok=True) # Create the directory if it doesn't exist file_names = [] with zipfile.ZipFile(file, "r") as zip_ref: zip_ref.extractall(extract_path) # Extract files into the specified directory # Walk through the directory structure and add files to the list for root, dirs, files in os.walk(extract_path): for file in files: if not file.startswith('.'): # Construct the file's full path full_path = os.path.join(root, file) # Subtract the base extraction path to show a relative path relative_path = os.path.relpath(full_path, extract_path) file_names.append(relative_path) return '\n'.join(file_names) # Join the list into a single string separated by newlines interface = gr.Interface(fn=unzip_file, inputs="file", outputs="text") interface.launch() # def greet(name): # return "Hello " + name + "!!" #iface = gr.Interface(fn=greet, inputs="text", outputs="text") #iface.launch()