http = require('http'); fs = require('fs'); port = 3000; host = '127.0.0.1'; server = http.createServer( function(req, res) { if (req.method == 'POST') { console.log("Handling POST request..."); res.writeHead(200, {'Content-Type': 'text/html'}); var body = ''; req.on('data', function (data) { body += data; }); req.on('end', function () { console.log("POST payload: " + body); res.end( body ); }); } else { console.log("Handling GET request..."); res.writeHead(200, {'Content-Type': 'text/html'}); var html = 'HTTP Server at http://' + host + ':' + port + ''; res.end(html); } }); server.listen(port, host); console.log('Listening at http://' + host + ':' + port);