Skip to content

Instantly share code, notes, and snippets.

@mick-io
Created August 5, 2019 19:59
Show Gist options
  • Save mick-io/22641f2f6ffeb27270785e224e4863f1 to your computer and use it in GitHub Desktop.
Save mick-io/22641f2f6ffeb27270785e224e4863f1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const http = require("http");
const PORT = process.argv[2] || 8000;
const server = http.createServer((req, res) => {
let data = "";
req.on("error", err => {
throw err;
});
req.on("data", chunk => {
data += chunk;
});
req.on("end", () => {
res.setHeader("Content-Type", "application/json")
res.write(data, () => res.end());
});
});
server.listen(PORT, () => {
console.log(`Dummy server listing on port: ${PORT}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment