Skip to content

Instantly share code, notes, and snippets.

@guydumais
Created March 6, 2021 14:48
Show Gist options
  • Save guydumais/a21af52e68e79feadefa614d5ee84bad to your computer and use it in GitHub Desktop.
Save guydumais/a21af52e68e79feadefa614d5ee84bad to your computer and use it in GitHub Desktop.
Node.js HTTP Server
require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment