app.post('/upload',upload.array('photos',30),function(req,res,next){
for (var index in req.files)
{
var file = req.files[index];
var loc = file.destination;
var output= uploadFolder+req.body.user+'/download/'+formatDate();
};
console.log('output: '+output);
console.log('loc: '+loc);
var cmd = 'python demo.py -i '+loc+' -o '+output+' --isDlib True'; //cmd demo.py
// res.write('File Processing..');
child_process.exec(cmd,function(err,stdout,stderr){
var fileLocation = output+'.zip';
console.log(fileLocation);
zipFolder(output,fileLocation, function(err) {
if(err) {
console.log('oh no!', err);
} else {
console.log('EXCELLENT');
res.download(fileLocation,'Files');
// res.redirect('/form');
}
});
});
});
Hi everyone, I've just started out with Node and I tried to build a simple server to let user upload their image. The image will then be changed to 3D by python.
Now I want to display a message when the user is waiting for the file transfer to complete.
I tried to send the message by response.write before the child_process ,and in the end I wish to redirect the website by route.
But I always get the error (The codes which I comment out. ):
Can't set headers after they are sent.
Can someone help me to fix it? Thanks a lot.