课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Middlewares and templating

Middlewares and templating

- [Tutor] Let's now continue with this file, and make it into an actual web server. If you noticed, when we cancel logged the Express object, that we're importing here, the top level of that object is a function. This indicates that the Express variable can be invoked, and that's actually the API from Express, to create a server object. We run that server using server.listen. This method takes in a few arguments. The first argument is the port, on which the server will be listening. Let's go with 8080. The second argument is the machine host, or the IP of the machine for this server. So, we can use local host in development, or 0.0.0.0 which probably works better on most machines. The third argument is the function. This is the function that will be executed, when the server is done mounting itself on that port. So, in here we can print a message to confirm, that the server is listening on that port. Note how I used…

内容