Skip to content

Instantly share code, notes, and snippets.

@myleshk
Last active October 20, 2017 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myleshk/129d96c36db252c3bcaf3ac058d70e3d to your computer and use it in GitHub Desktop.
Save myleshk/129d96c36db252c3bcaf3ac058d70e3d to your computer and use it in GitHub Desktop.
nodejs simple webserver test
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