var qs = require('querystring') require('http').createServer(function(req, res) { //res.writeHead(200, {'Content-Type': 'image/png'}) /*var stream = require('fs').createReadStream('image.png') stream.on('data', function(data) { res.write(data) }) stream.on('end', function() { res.end() })*/ //require('fs').createReadStream('image.png').pipe(res) if ('/' == req.url) { res.writeHead(200, {'Content-Type': 'text/html'}) res.end([ '<form method="POST" action="/url">', '<input type="text" name="name">', '<button>Submit</button>', '</form>' ].join('')) } else if ('/url' == req.url && 'POST' == req.method) { var body = '' req.on('data', function(data) { body += data }) req.on('end', function() { res.writeHead(200, {'Content-Type': 'text/html'}) res.end('Content-Type: ' + req.headers['content-type'] + 'Data:' + qs.parse(body).name) }) } else { res.writeHead(200, {'Content-Type': 'text/html'}) res.end('Not Found') } }).listen(3000) console.log(qs.parse('name=Guillermo'))