var http = require('http'); var fs = require('fs'); var Busboy = require('busboy'); var PORT = 6666; http.createServer(function(req, res) { if (req.url === '/') { res.writeHead(200, {'content-type': 'text/html'}); res.end('
'+ ''+ '
'); } else if (req.url === '/upload') { var busboy = new Busboy({headers: req.headers}); busboy.on('file', function(_, file) { file.pipe(fs.createWriteStream(__dirname + '/upload')); }); busboy.on('finish', function() { res.writeHead(200, {'Connection': 'close'}); res.end("That's all folks!"); }); req.pipe(busboy); } }).listen(PORT, function() { console.info('listening on http://0.0.0.0:' + PORT + '/'); });