Spaces:
Running
Running
© 2025 by JerryCoder
Browse files
app.py
CHANGED
|
@@ -50,26 +50,23 @@ def process_image(img_bytes: bytes):
|
|
| 50 |
output_bytes = remove(img_bytes)
|
| 51 |
|
| 52 |
# Upload to tmpfiles (temporary hosting)
|
| 53 |
-
files = {"file": ("output.png", output_bytes, "image/png")}
|
| 54 |
-
r = requests.post("https://tmpfiles.org/api/v1/upload", files=files, timeout=20)
|
| 55 |
-
r.raise_for_status()
|
| 56 |
-
data = r.json()
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
"
|
| 67 |
-
}
|
| 68 |
|
| 69 |
-
return {"status": "error", "message": "Upload failed"}
|
| 70 |
except Exception as e:
|
| 71 |
return {"status": "error", "message": str(e)}
|
| 72 |
-
|
| 73 |
# --------------------------
|
| 74 |
# POST: Upload file
|
| 75 |
# --------------------------
|
|
|
|
| 50 |
output_bytes = remove(img_bytes)
|
| 51 |
|
| 52 |
# Upload to tmpfiles (temporary hosting)
|
| 53 |
+
files = {"file": ("output.png", output_bytes, "image/png")}
|
| 54 |
+
r = requests.post("https://tmpfiles.org/api/v1/upload", files=files, timeout=20)
|
| 55 |
+
r.raise_for_status()
|
| 56 |
+
data = r.json()
|
| 57 |
|
| 58 |
+
if data.get("status") == "success":
|
| 59 |
+
return {
|
| 60 |
+
"status": "success",
|
| 61 |
+
"url": data["data"]["url"],
|
| 62 |
+
"creator": "Jerrycoder",
|
| 63 |
+
"telegram": "Oggy_workshop"
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return {"status": "error", "message": "Upload failed"}
|
|
|
|
| 67 |
|
|
|
|
| 68 |
except Exception as e:
|
| 69 |
return {"status": "error", "message": str(e)}
|
|
|
|
| 70 |
# --------------------------
|
| 71 |
# POST: Upload file
|
| 72 |
# --------------------------
|