-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (35 loc) · 925 Bytes
/
index.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
(function() {
var express = require('express');
var bodyParser = require('body-parser');
var parody = require('./parody/parody.js');
var fs = require('fs');
var port = process.env.PORT || 8000;
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.post('/twist', function(req, res) {
parody.createParody(
req.body.original || "",
req.body.numMatching || 2,
function(parodyText) {
res.send(parodyText);
});
});
app.get('/loggg', function(req, res) {
fs.appendFile('./log.log', '\n---\nloggg\n---\n', function(err) {
if (err) {
return res.send("err");
}
fs.readFile('./log.log', function(err, str) {
if (err) {
return res.send("nope");
}
res.send(str);
});
});
});
app.listen(port, function() {
console.log('Express server listening on port ' + port);
});
})();