-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
111 lines (97 loc) · 2.58 KB
/
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
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
111
var express = require('express');
var Twitter = require('twitter');
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
app = express();
app.set('port', (process.env.PORT || 3000));
client = new Twitter({
consumer_key: 'di5OGJMlDXdlIeZrtwS89cx2O',
consumer_secret: 'ux6OLwwu84cyggLXhrFvbklPxj4kR4MvEZmsbAzNbQPiiT2V7f',
access_token_key: '',
access_token_secret: ''
});
app.use('/scripts', express.static(__dirname + '/node_modules/'));
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'));
// SCRIPTS
app.get('/scripts/jquery.js', function (req, res) {
var jquery = require.resolve('jquery');
res.sendFile(jquery);
});
app.get('/scripts/bootstrap.js', function (req, res) {
var bootstrap = require.resolve('bootstrap');
res.sendFile(bootstrap);
});
app.get('/scripts/popper.js', function (req, res) {
var popper = require.resolve('popper');
res.sendFile(popper);
});
// Rotas
app.get('/', function (req, res) {
var options = {
root: __dirname,
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
res.sendFile("index.html", options);
});
app.use(express.static(__dirname + '/pages'));
app.use(express.static(__dirname));
app.get('/twitter', function (req, res) {
var options = {
root: __dirname + '/pages/twitter/',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
res.sendFile("twitter.html", options);
});
app.use('/tshoweett', express.static(__dirname + '/pages/screen/'));
app.get('/tshoweett', function (req, res) {
var options = {
root: __dirname + '/pages/screen/',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
res.sendFile("screen-show.html", options);
});
var idTweet;
app.get('/set/tweet', function (req, res) {
var params = req.url.split('=')[1];
if (params) {
idTweet = params;
res.send(params);
}
});
app.get('/get/tweet', function (req, res) {
if (idTweet)
res.send(idTweet);
else
res.send('Não tem numero')
});
app.get('/tt', function (req, res) {
var params = req.url.split('=')[1];
params = params[0] == '#' ? params : '#' + params;
client.get('search/tweets', {
q: params,
tweet_mode: 'extended',
count: 100,
include_entities: 1
}, function (error, tweets, response) {
if (!error) {
if (response)
res.json(JSON.parse(response.toJSON().body));
} else {
console.log(error);
}
});
});
app.listen(app.get('port'), function () {
console.log('Example app listening on port ', app.get('port'));
});