Create a web server with Node.js

In this tutorial I will explain to you how to create a webserver by using Node.js Framework. I have also created a video where you can see how it works.

So, to create a web server, I have created a js file called app.js.

Next, in the file app.js, I have used the module http.

var server = require('http');

Then I have writed a function to create a webserver:

var create = server.createServer(function(request,response)
{
response.writeHead(200,{"Content-Type":"text/html"});
response.write("
<h1>Hello World!</h1>
");
response.end();
});

To listen my server on port 100, I have used this code:

create.listen(100,'localhost');

Now, my web server is ready!

Video tutorial:









Leave a Comment