-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
53 lines (40 loc) · 734 Bytes
/
app.js
File metadata and controls
53 lines (40 loc) · 734 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Module dependencies
*/
var express = require('express')
var bodyParser = require('body-parser')
/**
* Initialize express app
*/
var app = express()
/**
* Databases
*/
var data = require('./data')
/**
* Config
*/
app.set('view engine', 'jade')
app.use(express.static('public'))
app.use(bodyParser.json())
/**
* Routes
*/
// Show app
app.get('/', function(req, res){
data.getBg = getBg
res.render('index', data)
})
// Get results
app.post('/', function(req, res){
res.json('ok')
})
/**
* Auxiliary background color helper
*/
function getBg(value){
if(value < 0.85) return "rgba(255, 0, 0, 0.3)"
if(value < 0.91) return "rgba(255, 255, 0, 0.3)"
return "rgba(0, 255, 0, 0.3)"
}
app.listen(3333)