Skip to content

Instantly share code, notes, and snippets.

@pranavbhargava
Created August 29, 2012 20:36
Show Gist options
  • Save pranavbhargava/3518564 to your computer and use it in GitHub Desktop.
Save pranavbhargava/3518564 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
fs = require('fs'),
http = require('http');
//
// Setup a very simple HTTP server to serve our routing map!
//
var server = http.createServer(function (request, res) {
// this is inside path which handles your HTTP POST method request
if(request.method === "POST") {
var data = "";
request.on("data", function(chunk) {
data += chunk;
});
request.on("end", function() {
console.log(data);
fs.writeFile("/tmp/AMP-Test-Results-POST", data, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
});
}//end if
/*var parts = request.url.split("/");
sys.puts(sys.inspect(parts));
var data = parts[1];
if(data != 'favicon.ico'){
console.log(data);
fs.writeFile("/tmp/AMP-Test-Results", data, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
}
res.writeHead(200,{'Content-Type':'text/plain'});
res.end("");*/
});
server.listen(8000);
sys.puts(' > http server started on port 8000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment