Node JS Tutorial | HTTP Server

Node JS Tutorial | HTTP Server REPL HERE

First lets install Node in our environment. I’m using A Debian distro.


1
2
3
sudo apt install nodejs
node -v
sudo apt install npm

Next lets use the HTTP Module


1
2
3
4
5
6
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write('Hello World!');
  res.end();
}).listen(8080);

We now have a running HTTP server.

Well, that’s it were done. Super simple HTTP server in Node. We should see a basic HTML page being served with “HELLO WORLD” as output. Check out the next tutorial and we will template an HTML page for our server to serve.

Related posts

One Thought to “Node JS Tutorial | HTTP Server”

  1. I was just telling my friend about that.

Comments are closed.