Created
August 5, 2019 19:59
-
-
Save mick-io/22641f2f6ffeb27270785e224e4863f1 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
#!/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