We already installed the Express, and so we are going to create an express app, so the first thing
is we are going to create a app today and we will keep the server so we can compare.
We have this code later.
So the first thing is we go to the top end state concern expressed equal to require express.
And next, we are going to set up the express app so actually we can copy and paste here.
We invoke definitions and create an instance of express app and stored in the constant app.
And we can call this content whatever we want, but commonly we call this app.
So the next thing is we need to do is actually listen for the request, which is listening for the iPod
3000.
And we need to do these things after listening to thousands, so we call cockatoos and here it automatically
infer that we want to use a localhost so we do not need to at the localhost hear this.
Also, we turned and in terms of server and just like this before, we also create a constant server
in the server dodgiest so that we can also create this.
But at a minute we do not need to do so.
So we have set up the Express and we are now listening for the request at three thousand.
But how do we respond to those requests?
And actually this already has an example.
So we copy and paste here.
So if we want to listen to that request, we can use this app to get.
And the first argument is the POF order, you know, you want to listen to.
So if you want to listen to four words, you put the fourth last year.
And the second argument is a function.
And these functions text in a request and a response object so we can do something if those for the
request object it contain the information about the request such as you are and also the method like
cat pose or other the response object we can use to send a response like this.
So first we had to start the app.
So we use the app rather than not one server because we are going to run this file.
So we go to localhost and we Dowton and Press enter.
You can see how the world is to work.
Instead of returning some task, we can also return the e-mail code.
So we had a and then the time will come to the UK mobile.
Now if we go to refresh the page, you infer the type of content that we are going to send to the browsers
and it automatically set the content type.
So we do not need to use the SAT had like this before and you can prove this by going to the network
tab and click on the localhost and then you go to the content type.
You can see it already set the content type as text or HTML.
The other good thing is it also inferred the status that we do not need to manually set because a lot
of the time we are going to set as two hundred.
So when you go to here, you can see the status quo is two hundred.
The request method is get and actually we can set the static manually, but at this point we will stay
to use the state has two hundred.
So we do not need to add the status quo here.