-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.js
More file actions
53 lines (36 loc) · 1.28 KB
/
routes.js
File metadata and controls
53 lines (36 loc) · 1.28 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
module.exports = function (app, fourChanService) {
app.get('/', function (req, res) {
res.render('index.jade');
/*fourChanService.getCategories(function (data) {
res.render('index.jade', { categories : data });
}); */
});
app.get('/board/:name', function (req, res) {
var boardName = req.params.name;
fourChanService.getBoard(boardName, function (data) {
res.render('board.jade', { name : boardName, threads : data });
});
});
app.get('/thread/:section/:id/:surl', function (req, res) {
var section = req.params.section;
var id = req.params.id;
var surl = req.params.surl;
fourChanService.getThread(section, id, surl, function (data) {
res.render('thread.jade', { threadName : surl, pythonOutput : data });
});
});
app.get('/test', function (req, res) {
var spawn = require('child_process').spawn,
command = spawn('python', ['./python/scrapper.py', [1,2,3], 'http://algo.com']);
command.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
command.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
command.on('close', function (code) {
console.log('child process exited with code ' + code);
});
res.render('test.jade');
});
};