Created
February 11, 2013 20:22
-
-
Save NickTomlin/4757283 to your computer and use it in GitHub Desktop.
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
var http = require('http'); | |
var url = require('url'); | |
function start(route,handle) { | |
function onRequest(request,response){ | |
var postData = ""; | |
var pathname = url.parse(request.url).pathname; | |
console.log("Request for " + pathname + " received"); | |
request.setEncoding("utf8"); | |
request.addListener("data", function(postDataChunk) { | |
postData += postDataChunk; | |
console.log("Received POST data chunk' " + | |
postDataChunk + "'."); | |
}); | |
request.addListener("end",function(){ | |
route(handle,pathname,response,postData); | |
}); | |
} | |
http.createServer(onRequest).listen(8888); | |
console.log("Server has started"); | |
} | |
exports.start = start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment