forked from tvance989/gizworks-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gizworks.js
54 lines (46 loc) · 1.32 KB
/
gizworks.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
var express = require('express');
var gallery = require('./lib/gallery.js');
var app = express();
// set up handlebars view engine
var handlebars = require('express3-handlebars').create({defaultLayout:'main'});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.set('port', process.env.PORT || 3000);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next){
res.locals.showTests = app.get('env')!=='production' && req.query.test==='1';
next();
});
app.get('/', function(req, res){
res.render('home');
});
app.get('/about', function(req, res){
res.render('about', {
pageTestScript: '/qa/tests-about.js'
});
});
app.get('/gallery', function(req, res){
res.render('gallery', {
gallery: gallery.getProjects()
});
});
app.get('/order', function(req, res){
res.render('order');
});
app.get('/contact', function(req, res){
res.render('contact');
});
// 404 catch-all handler
app.use(function(req, res, next){
res.status(404);
res.render('404');
});
// 500 error handler
app.use(function(req, res, next){
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')+'; press Ctrl-C to terminate.');
});