Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -169,6 +169,10 @@ app.get('/tooncubus', async (req, res) => {
|
|
| 169 |
}
|
| 170 |
try {
|
| 171 |
const result = await toonCubus(url);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
res.json(result);
|
| 173 |
setTimeout(async () => {
|
| 174 |
try {
|
|
@@ -177,7 +181,7 @@ app.get('/tooncubus', async (req, res) => {
|
|
| 177 |
} catch (err) {
|
| 178 |
console.error(`Error deleting file: ${err.message}`);
|
| 179 |
}
|
| 180 |
-
}, 330000); //
|
| 181 |
} catch (error) {
|
| 182 |
res.status(500).send('Error processing request');
|
| 183 |
}
|
|
@@ -252,7 +256,7 @@ async function downloadImages(imgList, tempDir, instanceID) {
|
|
| 252 |
}
|
| 253 |
|
| 254 |
async function createPDF(imagePaths, instanceID, tempDir) {
|
| 255 |
-
const pdfPath = path.join(
|
| 256 |
const doc = new PDFDocument({ autoFirstPage: false });
|
| 257 |
|
| 258 |
doc.pipe(fs.createWriteStream(pdfPath));
|
|
|
|
| 169 |
}
|
| 170 |
try {
|
| 171 |
const result = await toonCubus(url);
|
| 172 |
+
exec(`ls ${os.tmpdir()}`, (err, stdout) => {
|
| 173 |
+
if (err) console.error(err);
|
| 174 |
+
else console.log(stdout);
|
| 175 |
+
});
|
| 176 |
res.json(result);
|
| 177 |
setTimeout(async () => {
|
| 178 |
try {
|
|
|
|
| 181 |
} catch (err) {
|
| 182 |
console.error(`Error deleting file: ${err.message}`);
|
| 183 |
}
|
| 184 |
+
}, 330000); // 5 minutes
|
| 185 |
} catch (error) {
|
| 186 |
res.status(500).send('Error processing request');
|
| 187 |
}
|
|
|
|
| 256 |
}
|
| 257 |
|
| 258 |
async function createPDF(imagePaths, instanceID, tempDir) {
|
| 259 |
+
const pdfPath = path.join(os.tmpdir(), `${instanceID}.pdf`);
|
| 260 |
const doc = new PDFDocument({ autoFirstPage: false });
|
| 261 |
|
| 262 |
doc.pipe(fs.createWriteStream(pdfPath));
|