Skip to content

Instantly share code, notes, and snippets.

@shobhitsinghal624
Last active August 29, 2015 14:02
Show Gist options
  • Save shobhitsinghal624/8be0cfea4e8e0869a0a2 to your computer and use it in GitHub Desktop.
Save shobhitsinghal624/8be0cfea4e8e0869a0a2 to your computer and use it in GitHub Desktop.
a simple node.js based server for useful for testing
var http = require('http');
var querystring = require('querystring');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
console.log('#### [Start] Request ###');
console.log('Method: ' + req.method);
console.log('URL: ' + req.url);
console.log('Headers: ');
console.log(req.headers);
var queryData = "";
req.on('data', function(data) {
queryData += data;
});
req.on('end', function() {
query = querystring.parse(queryData);
console.log('Query: ');
console.log(query);
console.log('#### [End] Request ###');
});
res.end(req.method + ' ' + req.url);
}).listen(1338, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1338');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment