|
|
@ -83,20 +83,23 @@ function run_child(taskID) { |
|
|
|
} |
|
|
|
|
|
|
|
server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 }, { name: 'style_image', maxCount: 1 }]), function (req, res) { |
|
|
|
let max_epoch = req.body.max_epoch; |
|
|
|
let max_epoch = parseInt(req.body.max_epoch || "100"); |
|
|
|
let md5 = crypto.createHash('md5'); |
|
|
|
|
|
|
|
console.log(req.files); |
|
|
|
console.log("Epoch = " + max_epoch); |
|
|
|
|
|
|
|
if (!req.files.content_image || !req.files.style_image) { |
|
|
|
progress[taskID] = {percentage: 0, max_epoch: 0, status: -2}; |
|
|
|
if (max_epoch > 2000 || max_epoch <= 0 || !req.files.content_image || !req.files.style_image) { |
|
|
|
res.writeHead(444, { 'Content-type': 'text/html' }); |
|
|
|
res.end(fs.readFileSync("./html/invalidParam.html")); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let taskID = Date.now().toString(16) + md5.update(req.files.content_image[0].filename + req.files.style_image[0].filename).digest('hex'); |
|
|
|
|
|
|
|
relationfile[taskID] = {content: req.files.content_image[0].filename, style: req.files.style_image[0].filename}; |
|
|
|
progress[taskID] = {percentage: 0, max_epoch: parseInt(max_epoch), status: 0, wait: totalTask + queue.length + 1}; |
|
|
|
progress[taskID] = {percentage: 0, max_epoch: max_epoch, status: 0, wait: totalTask + queue.length + 1}; |
|
|
|
|
|
|
|
if (isIdle) { |
|
|
|
isIdle = false; |
|
|
|