добавить проверку для request.url
в основном, используя собственный код в качестве примера:
var server = http.createServer(function(req, res){
var output = {message: "Hello World!"};
var body = JSON.stringify(output);
res.writeHead(200, {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
});
//.split creates an array with strings from the given url
//req.url -> gives everything that's right after the http://localhost:8080/ portion
var requested = req.url.split("/");
output.message = "Hello " + requested[2]; // 0 is empty, 1 is "get"
res.end(output);
});
Надеюсь, что поможет.