Sanshruth commited on
Commit
18b16ea
Β·
verified Β·
1 Parent(s): 09ca2c2

initial_commit

Browse files
Files changed (2) hide show
  1. app.py +124 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import shutil
3
+ import os
4
+
5
+ # Supported target formats with display labels
6
+ FORMATS = {
7
+ "πŸ“ Word Document (.docx)": ".docx",
8
+ "πŸ“„ PowerPoint (.pptx)": ".pptx",
9
+ "πŸ“Š Excel Spreadsheet (.xlsx)": ".xlsx",
10
+ "πŸ–ΌοΈ JPEG Image (.jpg)": ".jpg",
11
+ "πŸ–ΌοΈ PNG Image (.png)": ".png",
12
+ "πŸ“„ PDF (.pdf)": ".pdf",
13
+ "πŸ“„ Text File (.txt)": ".txt",
14
+ "🎬 MP4 Video (.mp4)": ".mp4",
15
+ "🎡 MP3 Audio (.mp3)": ".mp3",
16
+ "πŸ“¦ RAR Archive (.rar)": ".rar",
17
+ "πŸ“¦ 7-Zip Archive (.7z)": ".7z",
18
+ "πŸ“¦ TAR Archive (.tar)": ".tar",
19
+ "🌐 HTML File (.html)": ".html",
20
+ "πŸ“‹ CSV File (.csv)": ".csv",
21
+ "πŸ”§ JSON File (.json)": ".json",
22
+ }
23
+
24
+ def convert_zip(zip_file, format_label):
25
+ if zip_file is None:
26
+ return None, "❌ Please upload a ZIP file first.", ""
27
+
28
+ ext = FORMATS.get(format_label)
29
+ if not ext:
30
+ return None, "❌ Please select a valid target format.", ""
31
+
32
+ original_name = os.path.basename(zip_file.name)
33
+ base_name = os.path.splitext(original_name)[0]
34
+ output_filename = base_name + ext
35
+ output_path = os.path.join("/tmp", output_filename)
36
+
37
+ print(f"Converting: {original_name} β†’ {output_filename}")
38
+ shutil.copy(zip_file.name, output_path)
39
+
40
+ ext_label = ext.lstrip('.')
41
+ prompt = (
42
+ f"I have changed the ZIP file to {ext_label} format. "
43
+ f"Please change the file extension back to .zip before processing."
44
+ )
45
+
46
+ status = (
47
+ f"βœ… Done! `{original_name}` β†’ `{output_filename}`\n\n"
48
+ f"πŸ“‹ Download the file below, then copy the prompt and paste it alongside your upload."
49
+ )
50
+
51
+ return output_path, status, prompt
52
+
53
+
54
+ with gr.Blocks(
55
+ title="ZipSlip β€” Upload ZIPs Anywhere",
56
+ theme=gr.themes.Soft(
57
+ primary_hue="red",
58
+ neutral_hue="gray",
59
+ font=[gr.themes.GoogleFont("DM Sans"), "sans-serif"],
60
+ ),
61
+ css="""
62
+ body, .gradio-container { font-family: 'DM Sans', sans-serif !important; }
63
+ #title { text-align: center; margin-bottom: 0.2em; font-size: 2em; }
64
+ #subtitle { text-align: center; color: #64748b; font-size: 0.95em; margin-bottom: 1.5em; }
65
+ #github_link { text-align: center; margin-bottom: 0.5em; }
66
+ .prompt-box textarea { font-family: 'DM Sans', sans-serif !important; font-size: 0.9em !important; }
67
+ footer { display: none !important; }
68
+ """,
69
+ ) as demo:
70
+
71
+ gr.Markdown("# πŸ“¦ ZipSlip", elem_id="title")
72
+ gr.Markdown(
73
+ "**https://github.com/SanshruthR/ZipSlip**",
74
+ elem_id="github_link",
75
+ )
76
+ gr.Markdown(
77
+ "Rename your ZIP so you can upload it to AI tools that block ZIP files β€” "
78
+ "Kimi, Claude, Gemini, Grok, DeepSeek, Copilot, and other web interfaces. "
79
+ "A ready-to-paste prompt is generated so the AI knows to treat it as a ZIP.",
80
+ elem_id="subtitle",
81
+ )
82
+
83
+ with gr.Row():
84
+ with gr.Column(scale=1):
85
+ zip_input = gr.File(
86
+ label="πŸ“‚ Upload your ZIP file",
87
+ file_types=[".zip"],
88
+ type="filepath",
89
+ )
90
+ format_dropdown = gr.Dropdown(
91
+ choices=list(FORMATS.keys()),
92
+ value="πŸ“ Word Document (.docx)",
93
+ label="πŸ”€ Disguise as format",
94
+ )
95
+ convert_btn = gr.Button("πŸš€ Disguise & Generate Prompt", variant="primary", size="lg")
96
+
97
+ with gr.Column(scale=1):
98
+ status_box = gr.Markdown(label="Status")
99
+ file_output = gr.File(label="⬇️ Download disguised file")
100
+ prompt_output = gr.Textbox(
101
+ label="πŸ“‹ Paste this prompt alongside your upload",
102
+ lines=3,
103
+ interactive=True,
104
+ show_copy_button=True,
105
+ elem_classes=["prompt-box"],
106
+ placeholder="Your prompt will appear here after converting…",
107
+ )
108
+
109
+ gr.Markdown(
110
+ "---\n"
111
+ "**How to use:** Upload your ZIP β†’ choose a disguise format β†’ download the renamed file "
112
+ "β†’ upload it to the AI tool β†’ paste the prompt so the AI knows to treat it as a ZIP.\n\n"
113
+ "> ⚠️ This tool only renames the file β€” no actual conversion happens. "
114
+ "The AI needs to rename it back to `.zip` before extracting."
115
+ )
116
+
117
+ convert_btn.click(
118
+ fn=convert_zip,
119
+ inputs=[zip_input, format_dropdown],
120
+ outputs=[file_output, status_box, prompt_output],
121
+ )
122
+
123
+ if __name__ == "__main__":
124
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==4.44.0