Skip to content

Instantly share code, notes, and snippets.

@tylerstalder
Created April 15, 2011 17:22
Show Gist options
  • Save tylerstalder/922070 to your computer and use it in GitHub Desktop.
Save tylerstalder/922070 to your computer and use it in GitHub Desktop.
Pulling and parsing the parameters from the URL
/*
* This is the standard hello world from nodejs.org with a couple lines added to parse URL parameters
*/
var http = require('http'),
url = require('url'),
qs = require('querystring');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var testQuery = url.parse(req.url, true);
console.log(testQuery.query);
res.end(JSON.stringify(testQuery.query));
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment