-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js.old
More file actions
54 lines (38 loc) · 1.15 KB
/
server.js.old
File metadata and controls
54 lines (38 loc) · 1.15 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
var express = require('express');
var enigmaX = require('./enigmax');
var key = enigmaX.newKey();
var app = express();
var server = {};
var data = {};
data.from = 'Bob';
data.to = 'Dave';
data.subject = 'Happy New Year!';
data.message = 'Just wanted to wish you a Happy New Year!';
data.num = 10;
function handlePost(request, response, next) {
console.log(request.body.message);
data.message = enigmaX.crypt(request.body.message);
response.send(data);
//next();
}
function onListening() {
console.log('Sever running on port ' + app.get('port'));
}
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.static(__dirname + '/public/'));
app.use(express.favicon(__dirname + "/ajax/skull.ico"));
app.use('/ajax', express.static(__dirname + '/ajax/'));
app.post('/ajax', handlePost);
app.set('port', 3000);
app.listen(app.get('port'), onListening);
/*function parseText(req, res, next){
if (req.is('text/*')) {
req.text = '';
req.setEncoding('utf8');
req.on('data', function(chunk){ req.text += chunk; });
req.on('end', next);
} else {
next();
}
}*/