Create Server using Pure Nodejs
As a Back-end Web Developer, Everyone needs to make a server either by Java, Nodejs, or some other Language.
Simply put, a Server is a type of computer which is running somewhere in the world and lets you communicate with your database and your materials. Without a Server, your information won't be saved for a limited time it will get deleted if you refresh your Web page.
Let's learn How we can make our simple Server using Nodejs
By using Nodejs, we can make our asynchronous server.
Make A Server.js file using your Code editor
//code written Down here
var http: require('http');
var server = http.createServer(function (req, res) {});
server.listen(5000);
console.log('Node.js web server at port 5000 is running...')
//code ends here
Lets understand this piece of code
//1 - Import Node.js core Module
var http: require('http');
//2 - Creating server handle incoming requests here..
var server = http.createServer(function (req, res) {});
//3 - Listen for any incoming requests
server.listen(5000);
In the above example, I just imported the HTTP module into our function and then created a server by which we can take a response or send our request that is GET, POST, PUT, and other methods. After that our server will run on port 5000.
Personally, I use POSTMAN for server handling and request doctoring
Comments