Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
UPLOAD_DIR = "uploads"
|
5 |
+
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
6 |
+
|
7 |
+
def save_file(file):
|
8 |
+
if file is None:
|
9 |
+
return "Please upload a file."
|
10 |
+
file_path = os.path.join(UPLOAD_DIR, file.name)
|
11 |
+
with open(file_path, "wb") as f:
|
12 |
+
f.write(file.read())
|
13 |
+
return f"✅ File `{file.name}` uploaded successfully!"
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
gr.Markdown("## 🖼️ Anonymous Image Upload\nDrop an image file below. No login required.")
|
17 |
+
with gr.Row():
|
18 |
+
uploader = gr.File(label="Upload Image", file_types=[".png", ".jpg", ".jpeg"])
|
19 |
+
output = gr.Textbox(label="Status")
|
20 |
+
uploader.change(fn=save_file, inputs=uploader, outputs=output)
|
21 |
+
|
22 |
+
demo.launch()
|