-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (34 loc) · 1.33 KB
/
Copy pathapp.js
File metadata and controls
41 lines (34 loc) · 1.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
var express = require('express');
var dbRoutes = require('./routes/routes.js');
var morgan = require('morgan');
var app = express();
// Set the views directory
app.set('views', __dirname + '/views');
// Define the view (templating) engine
app.set('view engine', 'ejs');
app.use(morgan('tiny')); // Log requests
// Routes
app.get('/', dbRoutes.index);
app.get('/login', dbRoutes.login);
app.get('/lighting', dbRoutes.light);
app.get('/log', dbRoutes.log);
app.get('/send', dbRoutes.send);
app.get('/:collection/:operation', dbRoutes.mongo);
app.get('/test', dbRoutes.test);
// Handle static files
app.use(express.static(__dirname + '/public'));
// Catch any routes not already handed with an error message
app.use(dbRoutes.errorMessage);
/*
* OpenShift will provide environment variables indicating the IP
* address and PORT to use. If those variables are not available
* (e.g. when you are testing the application on your laptop) then
* use default values of localhost (127.0.0.1) and 33333 (arbitrary).
*/
var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = process.env.OPENSHIFT_NODEJS_PORT || 50000;
// Start listening on the specific IP and PORT
app.listen(port, ipaddress, function() {
console.log('%s: Node server started on %s:%d ...',
Date(Date.now() ), ipaddress, port);
});