forked from sclorg/nodejs-ex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (22 loc) · 897 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// OpenShift sample Node application
var express = require('express'),
app = express(),
morgan = require('morgan');
Object.assign=require('object-assign');
app.engine('html', require('ejs').renderFile);
app.use(morgan('combined'))
var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080,
ip = process.env.IP || process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0',
backgroundColour = process.env.BACKGROUND || 'black';
app.get('/', function (req, res) {
res.render('index.html', { songLyrics: "Better The Devil You Know", backgroundColour: backgroundColour });
});
// error handling
app.use(function(err, req, res, next){
console.error(err.stack);
res.status(500).send('Something bad happened!');
});
app.use('/static', express.static('public'));
app.listen(port, ip);
console.log('Server running on http://%s:%s', ip, port);
module.exports = app;