Skip to content

Instantly share code, notes, and snippets.

@artemis15
Created August 13, 2019 11:12
Show Gist options
  • Save artemis15/55c3186e43ed25e3680a790376c9c8bb to your computer and use it in GitHub Desktop.
Save artemis15/55c3186e43ed25e3680a790376c9c8bb to your computer and use it in GitHub Desktop.
Sample Node.js Server
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