Skip to content

Instantly share code, notes, and snippets.

@lancecarlson
Created June 18, 2010 15:35
Show Gist options
  • Save lancecarlson/443789 to your computer and use it in GitHub Desktop.
Save lancecarlson/443789 to your computer and use it in GitHub Desktop.
var responseMap = {};
responseMap["/"] = function (req, res) {
// if (req.method === "GET")
sys.puts("getting");
var body = JSON.stringify({blah: "blah"});
sys.puts(sys.inspect(body));
res.writeHead(200, { "Content-Type": "text/json", "Content-Length:": body.length});
res.end(body);
};
http.createServer(function (req, res) {
var handler = responseMap[url.parse(req.url).pathname] || notFound;
handler(req, res);
}).listen(config.port, config.host);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment