Домой United States USA — software Node.js – Working With Web Servers and Web Frameworks

Node.js – Working With Web Servers and Web Frameworks

423
0
ПОДЕЛИТЬСЯ

In this post, we will understand how we can use Node.js in developing web applications and APIs.
Let’s be friends:
Comment (0)
Join the DZone community and get the full member experience.
Welcome to the future. Life is good, but it can be better. And why shouldn’t it be? All you need is to want it. Think about finally having everything you always wanted.
— Max Lord (Wonder Woman 1984)
I won’t say that I thought of Node.js when I first hear Max Lord saying those words in the trailer of upcoming wonder woman movie. However, it is close when we talk about building applications using Node.js. From working with devices to building web applications, sometimes that’s all you need.
In one of my previous posts, I wrote a brief introduction about Node.js. Node can be used in many places and today I will write about how Node can be used in web development. My idea is to keep these articles simple and same time build a path for more complex upcoming posts. If you are new to Node, I will suggest to first check my previous article here on DZone on this link, which will provide you the background context and will make it easy for you the follow the topics we are going to cover. So let’s start.
Node has a built-in web-server and the code above is demonstrating a very basic web server. Actually, I took this screenshot from my last article, and here we are going to understand a little bit more in detail.
createServer is a higher-order function coz it receives another function as parameter. We could have write the code as following as well:
requestListener function receives two arguments. These are positional arguments:
req = Represent the request side of the request-event.

Continue reading...