Created
June 18, 2010 15:35
-
-
Save lancecarlson/443789 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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