Skip to content

Instantly share code, notes, and snippets.

@adamcfraser
Created May 4, 2015 06:48
Show Gist options
  • Save adamcfraser/3987479d0d87fc43e337 to your computer and use it in GitHub Desktop.
Save adamcfraser/3987479d0d87fc43e337 to your computer and use it in GitHub Desktop.
test http server with count
var http = require('http');
var qs = require('querystring')
var count = 0
http.createServer(function (req, res) {
var body = ''
req.on('data',function(data) {
body += data;
})
req.on('end',function() {
var post = qs.parse(body)
count ++
console.log(post)
console.log('Count:' + count)
})
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello!');
}).listen(9091, 'localhost');
console.log('Server running at http://localhost:9091/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment