-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (25 loc) · 844 Bytes
/
app.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
31
32
'use strict';
var express = require('express'),
config = require('./config'),
_ = require('lodash'),
fs = require('fs'),
app = express();
app.set("view options", {layout: false});
app.use(express.static('public'));
app.use(express.static('common'));
app.use(express.static('node_modules'));
app.get('/:dashboard', function(req, res) {
var dasboardNames = fs.readdirSync('./public/dashboards');
var isExist = _.includes(dasboardNames, req.params.dashboard + ".html");
if(!isExist){
res.send('Dashboard ' + req.params.dashboard + ' does not exist!');
return;
}
var template = fs.readFileSync('./common/index.html');
res.write(template);
res.end();
});
app.listen(config.server.PORT, function() {
console.log('Goodly is started! Go to: http://localhost:%s',config.server.PORT);
console.log('To terminate it: Ctrl + C');
});