Skip to content

Commit 6a58d48

Browse files
author
Edward Muller
committed
Pull port off the environment, default to 3000
1 parent 1c2b58b commit 6a58d48

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var express = require('express');
1616
var bodyParser = require('body-parser');
1717
var app = express();
1818

19+
app.set('port', (process.env.PORT || 3000));
20+
1921
app.use('/', express.static(path.join(__dirname, 'public')));
2022
app.use(bodyParser.json());
2123
app.use(bodyParser.urlencoded({extended: true}));
@@ -39,6 +41,7 @@ app.post('/comments.json', function(req, res) {
3941
});
4042
});
4143

42-
app.listen(3000);
4344

44-
console.log('Server started: http://localhost:3000/');
45+
app.listen(app.get('port'), function() {
46+
console.log('Server started: http://localhost:' + app.get('port') + '/');
47+
});

0 commit comments

Comments
 (0)