-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (28 loc) · 934 Bytes
/
server.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
express = require('express');
app = express();
server = require('http').createServer(app);
io = require('socket.io').listen(server);
twit = require('./config.js').twitter;
app.configure( function() {
app.use(express.static('./static'));
});
app.get('/', function(req,res){
res.render('index.jade', {title: 'Picturely'});
});
app.get('/search', function(req,res){
q = req.query.q + ' -RT pic.twitter.com OR yfrog OR instagr.am OR twitpic OR lockerz OR instagram.com';
twit.search(q, {rpp: '100'}, function(err, data) {
if (err) {
res.render('search.jade', {error: 'true'});
} else {
results = data.statuses.filter(function (tweet) {
return tweet.entities.media != null
});
res.render('search.jade', {title: 'Picturely', q: req.query.q, results: results});
}
});
});
var port = process.env.PORT || 3000;
server.listen(port);
io.sockets.on('connection', function(socket) {
});