Skip to content

Instantly share code, notes, and snippets.

@vdel26
Last active August 29, 2015 13:55
Show Gist options
  • Save vdel26/8691923 to your computer and use it in GitHub Desktop.
Save vdel26/8691923 to your computer and use it in GitHub Desktop.
simple node.js debugging server
/*
* dummy API that returns the endpoint that was called
* and the apikey in JSON format
*/
var http = require('http');
var server = http.createServer(function (req, res) {
var responseContent = {};
res.writeHead(200, {'Content-type': 'application/json'});
// send back endpoint, apikey and headers
responseContent.endpoint = req.url.split('?')[0];
// responseContent.apikey = req.url.split('?user_key=')[1];
responseContent.headers = req.headers;
res.end(JSON.stringify(responseContent, null, '\t'));
});
server.listen(8000, '0.0.0.0');
console.log('server running at localhost:8000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment