June 2014
Intermediate to advanced
696 pages
38h 52m
English
To implement Express as the HTTP server for a Node.js application, you need to create an instance and begin listening on a port. The following three lines of code start a very rudimentary Express server listening on port 8080:
var express = require('express');var app = express();app.listen(8080);
The app.listen(port) call binds the underlying HTTP connection to the port and begins listening on it. The underlying HTTP connection is the same connection produced using the listen() method on a Server object created using the http library discussed in Chapter 7 “Implementing HTTP Services in Node.js.”
In fact, the value returned by express() is actually a callback function that maps to the ...
Read now
Unlock full access