-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtweetSentiment.js
46 lines (40 loc) · 1.16 KB
/
tweetSentiment.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
var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var stream = require('./stream');
var historyTweets = require('./historicalTweet');
var historySentimentResult = require('./historicalSentimentResult');
app.set('port', process.env.PORT || '3000');
server.listen(app.get('port'), function() {
console.log("listening on port "+ app.get("port"));
});
app.get('/sentimentresult', function(req, res) {
historySentimentResult(function(data){
res.json(data);
});
});
app.use(express.static(__dirname + '/public'));
app.get('/dorlingCartogram', function(req, res) {
res.sendFile(__dirname + '/public/dorlingCartogram.html');
})
app.get('/test', function(req, res) {
res.sendFile(__dirname + '/public/test.html');
})
io.on('connection', function(socket) {
console.log("socket connection is on");
stream(function(data) {
console.log("streaming");
socket.emit('tweet', data);
});
});
/*app.get('/stream', function(req, res) {
stream(function(data) {
res.json(data);
});
});*/
app.get('/history', function(req, res) {
historyTweets(function(data) {
res.json(data);
});
});