How can you use URL query strings in NodeJS like PHP's $_GET["query"] command?
http://php.net/manual/en/reserved.variables.get.php
Say for example you wanted to extend the code below to use a ?option=1 on the /page001 part.
So visiting ServerURL/page001?option=1 would write "Page1: Option 001 Selected".
And ServerURL/page001?option=2 would write "Page1: Option 002 Selected" etc.
var http = require('http');
var fs = require("fs");
var location = require('location-href');
var HttpDispatcher = require('httpdispatcher');
var dispatcher = new HttpDispatcher();
////////////////////
var http=require('http');
var url=require('url');
var server=http.createServer(function(req,res){
var pathname=url.parse(req.url).pathname;
switch(pathname){
case '/page001':
res.end('<div id="page001"><h2>Page 001</h2><div>Page 001 Content</div></div>');
console.log("Page 001 Loaded");
break;
case '/page002':
res.end('<div id="page002"><h2>Page 002</h2><div>Page 002 Content</div></div>');
console.log("Page 002 Loaded");
break;
default:
res.end('<div id="default"><h2>Default</h2><div>This is the default page</div></div>');
console.log("Default page was loaded");
break;
}
}).listen(8080);
console.log("Running on Port 8080");
req(by console.log, for example) and see what's inside, there's a lot of interesting stuff in it.