Skip to content

Instantly share code, notes, and snippets.

@baflo
Created August 2, 2019 07:32
Show Gist options
  • Save baflo/2dcb110b3798e5d5c146f1cb7bf0965c to your computer and use it in GitHub Desktop.
Save baflo/2dcb110b3798e5d5c146f1cb7bf0965c to your computer and use it in GitHub Desktop.
quick node server
http.createServer(function(r, s) {
var body = [];
r.on("data", function(chunk) {
body.push(chunk)
});
r.on("end", function() {
body = Buffer.concat(body).toString();
body = r.headers["content-type"] === "application/json" ? JSON.parse(body) : body;
console.log(r.method, r.url, r.headers, JSON.stringify(body, null, 2));
s.write("OK");
s.end();
});
}).listen(1330);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment