In this video we are going to learn about Creating a Server.
The Node.js framework is mostly used to create server-based applications.
The framework can easily be used to create web servers which can serve content to users.
There are a variety of modules such as the \"http\" and \"request\" module, which helps in processing server related requests in the webserver space.
We will have a look at how we can create a basic web server application using Node js.
Lets create http web server.
For that goto the project and here inside the index.js file and write the following code.


var http=require('http');
var server = http.createServer(function(req,res){
res.writeHead(200,{
'Content-Type':'text/plain'
});
res.end('Hello World!');
});
server.listen(3000);
console.log(\"Server is listening on port 3000\");


Now run this.
So goto the command prompt and just run index.js file.

node index.js


Now its running on localhost port 3000.
So lets check.
Switch to the browser and just type into url localhost:3000.
You can see here the text hello world!.

Now lets get the requested url.
So here add the following code.


var http=require('http');
var server = http.createServer(function(req,res){
res.writeHead(200,{
'Content-Type':'text/plain'
});
res.end('requested url is '+req.end);
});
server.listen(3000);
console.log(\"Server is listening on port 3000\");



Now lets check.
You can the request url is /.
If I change the url here /home.
Now you can see the url is home.
So in this way you can create server in node js.