Skip to content

Instantly share code, notes, and snippets.

@thebinarypenguin
Created March 6, 2016 13:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thebinarypenguin/122cda772438c80ad683 to your computer and use it in GitHub Desktop.
Save thebinarypenguin/122cda772438c80ad683 to your computer and use it in GitHub Desktop.
"Hello World" HTTP server using node.js
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