-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
91 lines (70 loc) · 1.88 KB
/
server.js
File metadata and controls
91 lines (70 loc) · 1.88 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var express = require('express'),
path = require('path'),
http = require('http'),
fs = require('fs'),
hbs = require('hbs');
var app = express();
app.use(express.static(path.join(__dirname, 'public')));
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'app/views'));
// ============================================
//
// Handlebars customization
hbs.registerPartials(__dirname + '/views/partials');
var blocks = {};
hbs.registerHelper('extend', function(name, context) {
var block = blocks[name];
if (!block) {
block = blocks[name] = [];
}
block.push(context.fn(this)); // for older versions of handlebars, use block.push(context(this));
});
hbs.registerHelper('block', function(name) {
var val = (blocks[name] || []).join('\n');
// clear the block
blocks[name] = [];
return val;
});
// END Handlebars customization
//
// ============================================
//
// ROUTES
app.get("/", function(req, res) {
res.render('index', {
title: 'Choose your experience - Drunk Bottle'
});
});
app.get("/adult", function(req, res) {
res.render('adult', {
title: 'Click to begin - Adults - Drunk Bottle'
});
});
app.get("/youth", function(req, res) {
res.render('youth', {
title: 'Choose your gender to begin - Youths - Drunk Bottle'
});
});
app.get("/youth/male", function(req, res) {
res.render('youth', {
title: 'Males - Youths - Drunk Bottle'
});
});
app.get("/youth/female", function(req, res) {
res.render('youth', {
title: 'Females - Youths - Drunk Bottle'
});
});
app.get("/youth/activities/:activity", function(req, res) {
var activity = req.params.activity;
res.render('youth', {
title: activity + ' - Youths - Drunk Bottle'
});
});
// END ROUTES
//
// ============================================
var port = process.env.PORT || 8080;
app.listen(port, function() {
console.log("Listening on " + port);
});