Created
March 6, 2016 13:27
-
-
Save thebinarypenguin/122cda772438c80ad683 to your computer and use it in GitHub Desktop.
"Hello World" HTTP server using node.js
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
const http = require('http'); | |
const name = 'node-hello-world'; | |
const port = '8888'; | |
const app = new http.Server(); | |
app.on('request', (req, res) => { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.write('Hello World'); | |
res.end('\n'); | |
}); | |
app.listen(port, () => { | |
console.log(`${name} is listening on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment