-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
110 lines (98 loc) · 3.1 KB
/
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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var express = require('express'),
app = express(),
engines = require('consolidate'),
nunjucks = require('nunjucks'),
bodyParser = require('body-parser'),
port = process.env.PORT || 8080;
assert = require('assert');
app.engine('html', engines.nunjucks);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.get("/", function(req, res, next) {
res.render('splash', {'unit_name': 'Enigma: An Introduction to Cryptography'});
});
app.get("/caesar-shift/encrypt", function(req, res, next) {
res.render('base_caesar_shift_exercise', {'exercise_type': 'Encrypt',
'next_route': '/caesar-shift/decrypt',
'red': 40,
'green': 40,
'blue': 20,
'opacity': 0.2});
});
app.get("/caesar-shift/decrypt", function(req, res, next){
res.render('base_caesar_shift_exercise', {'exercise_type': 'Decrypt',
'next_route': '/password/encrypt',
'red': 80,
'green': 20,
'blue': 40,
'opacity': 0.2})
});
app.get("/caesar-shift/sandbox", function(req, res, next){
res.render('base_caesar_shift_exercise', {'exercise_type': 'Sandbox',
'next_route': '',
'red': 40,
'green': 20,
'blue': 40,
'opacity': 0.2});
});
app.get("/password/encrypt", function(req, res, next){
res.render('base_password_exercise', {'title': 'Vigenere Cipher Encryption',
'exercise_type': 'Encrypt',
'input_label': 'Plaintext',
'output_label': 'Ciphertext',
'next_route': '/password/decrypt',
'red': 0,
'green': 0,
'blue': 100,
'opacity': 0.2,
js_source: true});
});
app.get("/password/decrypt", function(req, res, next){
res.render('base_password_exercise', {'title': 'Vigenere Cipher Decryption',
'exercise_type': 'Decrypt',
'input_label': 'Ciphertext',
'output_label': 'Plaintext',
'next_route': '/enigma/encrypt',
'red': 0,
'green': 50,
'blue': 50,
'opacity': 0.2,
js_source: true});
});
app.get("/password/sandbox", function(req, res, next){
res.render('base_password_exercise', {'title': 'Vigenere Cipher Sandbox',
'exercise_type': 'Sandbox',
'input_label': 'Starting Text',
'output_label': 'Ending Text',
'red': 50,
'green': 0,
'blue': 50,
'opacity': 0.2,
js_source: true});
});
app.get("/enigma/encrypt", function(req, res, next){
res.render('base_enigma_exercise', {'title': 'Enigma Machine Encryption',
'image_path': '../images/password-sandbox.png',
'exercise_type': 'Encrypt',
'input_label': 'Plaintext',
'output_label': 'Ciphertext',
'next_route': '/end'
});
});
app.get("/enigma/sandbox", function(req, res, next){
res.render('base_enigma_exercise', {'title': 'Enigma Machine Sandbox',
'image_path': '../images/password-sandbox.png',
'exercise_type': 'Sandbox',
'input_label': 'Starting Text',
'output_label': 'Ending Text',
});
});
app.get("/end", function(req, res, next){
res.render('end_screen');
})
// Running the web server
var server = app.listen(port, function() {
console.log('Express server listening on port %s.', server.address().port);
});