Spaces:
Sleeping
Sleeping
Upload 17 files
Browse files- dashboardlogic.js +2 -3
- server.js +6 -3
dashboardlogic.js
CHANGED
|
@@ -363,12 +363,11 @@ async function deleteFile(id) {
|
|
| 363 |
|
| 364 |
try {
|
| 365 |
loading(true);
|
| 366 |
-
const
|
| 367 |
-
const result = await client.predict("/delete_file_secure", {
|
| 368 |
user_id: currentUser,
|
| 369 |
password: currentPassword,
|
| 370 |
filename: file.name,
|
| 371 |
-
});
|
| 372 |
|
| 373 |
console.log('Deleted:', file.name);
|
| 374 |
|
|
|
|
| 363 |
|
| 364 |
try {
|
| 365 |
loading(true);
|
| 366 |
+
const result = await callSecureApi("/delete_file_secure", withTokens({
|
|
|
|
| 367 |
user_id: currentUser,
|
| 368 |
password: currentPassword,
|
| 369 |
filename: file.name,
|
| 370 |
+
}));
|
| 371 |
|
| 372 |
console.log('Deleted:', file.name);
|
| 373 |
|
server.js
CHANGED
|
@@ -12,6 +12,10 @@ const app = express();
|
|
| 12 |
const PORT = process.env.PORT || 7860;
|
| 13 |
const HF_TOKEN = process.env.HF_TOKEN;
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if (!HF_TOKEN) {
|
| 16 |
console.error("HF_TOKEN is not set in environment variables!");
|
| 17 |
process.exit(1);
|
|
@@ -33,8 +37,7 @@ app.post("/api/proxy", async (req, res) => {
|
|
| 33 |
}
|
| 34 |
|
| 35 |
try {
|
| 36 |
-
|
| 37 |
-
const client = await Client.connect("pockit-cloud/main", { hf_token: HF_TOKEN });
|
| 38 |
|
| 39 |
// Now 'args' only contains the actual model inputs
|
| 40 |
const result = await client.predict(fn, args);
|
|
@@ -77,7 +80,7 @@ app.post("/api/upload", upload.single("file"), async (req, res) => {
|
|
| 77 |
}
|
| 78 |
const custom_name = req.body.custom_name || req.file.originalname;
|
| 79 |
try {
|
| 80 |
-
const client = await
|
| 81 |
const result = await client.predict("/upload_file_secure", {
|
| 82 |
user_id,
|
| 83 |
password,
|
|
|
|
| 12 |
const PORT = process.env.PORT || 7860;
|
| 13 |
const HF_TOKEN = process.env.HF_TOKEN;
|
| 14 |
|
| 15 |
+
// Reuse a single Gradio client so state (like dropdown choices)
|
| 16 |
+
// is preserved across related function calls.
|
| 17 |
+
const clientPromise = Client.connect("pockit-cloud/main", { hf_token: HF_TOKEN });
|
| 18 |
+
|
| 19 |
if (!HF_TOKEN) {
|
| 20 |
console.error("HF_TOKEN is not set in environment variables!");
|
| 21 |
process.exit(1);
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
try {
|
| 40 |
+
const client = await clientPromise;
|
|
|
|
| 41 |
|
| 42 |
// Now 'args' only contains the actual model inputs
|
| 43 |
const result = await client.predict(fn, args);
|
|
|
|
| 80 |
}
|
| 81 |
const custom_name = req.body.custom_name || req.file.originalname;
|
| 82 |
try {
|
| 83 |
+
const client = await clientPromise;
|
| 84 |
const result = await client.predict("/upload_file_secure", {
|
| 85 |
user_id,
|
| 86 |
password,
|