Created
April 15, 2011 17:22
-
-
Save tylerstalder/922070 to your computer and use it in GitHub Desktop.
Pulling and parsing the parameters from the URL
This file contains 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
/* | |
* 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