Spaces:
Sleeping
Sleeping
Upload 17 files
Browse files- dashboardlogic.js +11 -5
- server.js +21 -0
dashboardlogic.js
CHANGED
|
@@ -363,11 +363,17 @@ async function deleteFile(id) {
|
|
| 363 |
|
| 364 |
try {
|
| 365 |
loading(true);
|
| 366 |
-
const
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
console.log('Deleted:', file.name);
|
| 373 |
|
|
|
|
| 363 |
|
| 364 |
try {
|
| 365 |
loading(true);
|
| 366 |
+
const resp = await fetch('/api/delete', {
|
| 367 |
+
method: 'POST',
|
| 368 |
+
headers: { 'Content-Type': 'application/json' },
|
| 369 |
+
body: JSON.stringify({
|
| 370 |
+
user_id: currentUser,
|
| 371 |
+
password: currentPassword,
|
| 372 |
+
filename: file.name,
|
| 373 |
+
}),
|
| 374 |
+
});
|
| 375 |
+
if (!resp.ok) throw new Error('Delete HTTP ' + resp.status);
|
| 376 |
+
const result = await resp.json();
|
| 377 |
|
| 378 |
console.log('Deleted:', file.name);
|
| 379 |
|
server.js
CHANGED
|
@@ -91,6 +91,27 @@ app.post("/api/upload", upload.single("file"), async (req, res) => {
|
|
| 91 |
}
|
| 92 |
});
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
app.use(express.static("."));
|
| 95 |
|
| 96 |
app.listen(PORT, () => {
|
|
|
|
| 91 |
}
|
| 92 |
});
|
| 93 |
|
| 94 |
+
app.post("/api/delete", async (req, res) => {
|
| 95 |
+
const { user_id, password, filename } = req.body || {};
|
| 96 |
+
|
| 97 |
+
if (!user_id || !password || !filename) {
|
| 98 |
+
return res.status(400).json({ error: "Missing user_id, password, or filename" });
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
try {
|
| 102 |
+
const client = await Client.connect("pockit-cloud/main", { hf_token: HF_TOKEN });
|
| 103 |
+
const result = await client.predict("/delete_file_secure", {
|
| 104 |
+
user_id,
|
| 105 |
+
password,
|
| 106 |
+
filename,
|
| 107 |
+
});
|
| 108 |
+
res.json({ data: result.data });
|
| 109 |
+
} catch (err) {
|
| 110 |
+
console.error("Delete error:", err);
|
| 111 |
+
res.status(500).json({ error: "Delete failed", details: err.message });
|
| 112 |
+
}
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
app.use(express.static("."));
|
| 116 |
|
| 117 |
app.listen(PORT, () => {
|