-
Notifications
You must be signed in to change notification settings - Fork 3
/
web.js
38 lines (33 loc) · 919 Bytes
/
web.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
require('newrelic');
var path = require('path')
, express = require('express')
, bzzfd = require('./bzzfd.js');
// Set up Express
var app = express();
app.configure(function() {
app.use(express.logger());
app.use(express.static(path.join(__dirname, 'public')));
app.set('port', process.env.PORT || 5000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(app.router);
});
app.get('/', function (req, res) {
res.render('index');
});
app.get('/article', function (req, res) {
var headline = req.query.headline;
bzzfd.makeArticle(headline, function (err, items) {
if (err)
console.error(err);
res.render('article', {
headline: headline,
items: items
});
});
});
app.listen(app.get('port'), function() {
console.log('Listening on ' + app.get('port'));
});