Last active
August 29, 2015 14:02
-
-
Save shobhitsinghal624/8be0cfea4e8e0869a0a2 to your computer and use it in GitHub Desktop.
a simple node.js based server for useful for testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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