Skip to content

Instantly share code, notes, and snippets.

@upning
Created November 13, 2022 12:02
Show Gist options
  • Save upning/33ac74db2a05546688353c48bc5f39ab to your computer and use it in GitHub Desktop.
Save upning/33ac74db2a05546688353c48bc5f39ab to your computer and use it in GitHub Desktop.
[NodeJS Hello World] My first introduction to server environment #nodejs
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
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