mirror of
https://github.com/geerlingguy/ansible-for-devops.git
synced 2024-05-19 06:50:03 +00:00
express's `server.listen` has an asynchronous nature and it's API enables providing a callback that is fired upon success. Now the success messaage is logged only when the server has been set up and listening on provided socket address, otherwise the error stack trace is printed.
15 lines
412 B
JavaScript
15 lines
412 B
JavaScript
// Simple Express web server.
|
|
// @see http://howtonode.org/getting-started-with-express
|
|
|
|
// Load the express module.
|
|
var express = require('express');
|
|
var app = express();
|
|
|
|
// Respond to requests for / with 'Hello World'.
|
|
app.get('/', function(req, res){
|
|
res.send('Hello World!');
|
|
});
|
|
|
|
// Listen on port 80 (like a true web server).
|
|
app.listen(80, () => console.log('Express server started successfully.'));
|