-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
73 lines (62 loc) · 1.51 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var express = require('express');
var app = express();
var port = process.env.PORT || 5000;
app.set('view engine', 'ejs');
app.get('/', function(req, res){
// ejs render automatically looks in views folder for 'index.ejs'
res.render('index');
});
app.get('/name', function(req, res){
// the variable "name" will be available in the template
res.render('name', {name: 'Cory'});
});
app.get('/loops', function(req, res){
var kardashians = [
'Robert',
'Khloé',
'Rob',
'Kendall',
'Kylie',
'Brody',
'Brandon',
'Kim'
];
// There will be a variable named "kardashians" available
// in the loops.ejs template
res.render('loops', {kardashians: kardashians});
});
app.get('/loops-louder', function(req, res){
var kardashians = [
'Robert',
'Khloé',
'Rob',
'Kendall',
'Kylie',
'Brody',
'Brandon',
'Kim'
];
// There will be a variable named "kardashians" and another named
// "louder" available
// in the loops.ejs template
res.render('loops-with-volume', {kardashians: kardashians, louder: true});
});
app.get('/loops-quieter', function(req, res){
var kardashians = [
'Robert',
'Khloé',
'Rob',
'Kendall',
'Kylie',
'Brody',
'Brandon',
'Kim'
];
// There will be a variable named "kardashians" and another named
// "louder" available
// in the loops.ejs template
res.render('loops-with-volume', {kardashians: kardashians, louder: false});
});
app.listen(port, function(){
console.log('listening on ',port);
});