Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Header Debugger I wrote in NodeJs
var express = require("express");
var fs = require("fs");
var app = express();
app.post("/", function(req, res){
var date = Date.now();
var fileName = "POST.json";
console.log("POST / @" + date);
fs.writeFile(fileName, JSON.stringify({ "HEADERS": req.headers}, undefined, 2), function fileWriteComplete(err){
if(err){
console.log(" Error writing to file " + err);
} else{
console.log(" File saved " + fileName);
}
});
res.send("Ok");
});
app.listen(3000, function(){
console.log("App listening on port 3000");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment