-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeadowlark5-testing.js
More file actions
49 lines (38 loc) · 1.04 KB
/
Copy pathmeadowlark5-testing.js
File metadata and controls
49 lines (38 loc) · 1.04 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
var express = require('express');
var app = express();
app.set('port', process.env.PORT || 3000);
var handlebars = require('express-handlebars').create({defaultLayout:'main'});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.use(express.static(__dirname+'/public'));
app.use(function(req, res, next){
res.locals.showTests = app.get('env') !== 'production' && req.query.test === '1';
next();
})
var fortunes = [
"line 1",
"sentence b",
"row c",
"d",]
app.get('/', function(req, res){
res.render('home');
});
app.get('/about', function(req, res){
var randomFortune = fortunes[Math.floor(Math.random() * fortunes.length)];
res.render('about', {
fortune:randomFortune,
pageTestScript: '/qa/tests-about.js'
});
});
app.use(function (req, res){
res.status(404);
res.render('404');
});
app.use(function (req, res){
console.error(err.stack);
res.status(500);
res.render('500');
});
app.listen(app.get('port'), function(){
console.log('express started on http://localhost:' + app.get('port') + '');
});