The express.js program is saved with ".js
" extension.
Example :
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Welcome to Free Time Learning!');
});
var server = app.listen(8000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
}); ​
When you run the Node.js
command prompt, the app will listen at the specified server address and give the following output.
Output :
Welcome to Free Time Learning!