|
import zipfile |
|
import gradio as gr |
|
import os |
|
|
|
def unzip_file(file): |
|
extract_path = "extracted_files" |
|
os.makedirs(extract_path, exist_ok=True) |
|
file_names = [] |
|
with zipfile.ZipFile(file, "r") as zip_ref: |
|
zip_ref.extractall(extract_path) |
|
|
|
for root, dirs, files in os.walk(extract_path): |
|
for file in files: |
|
if not file.startswith('.'): |
|
|
|
full_path = os.path.join(root, file) |
|
|
|
relative_path = os.path.relpath(full_path, extract_path) |
|
file_names.append(relative_path) |
|
|
|
return '\n'.join(file_names) |
|
|
|
interface = gr.Interface(fn=unzip_file, inputs="file", outputs="text") |
|
interface.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|