forked from jdaccarett/anatomy3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (32 loc) · 800 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
34
35
var express = require('express');
var http = require('http');
var app = express();
var handlebars = require('express-handlebars').create({
default: 'main'
});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
//set port
var port = process.env.PORT || 8080;
//Allows me to use stylesheets in handlebars.
app.use(express.static('public'));
//HOME PAGE
app.get('/', function(req, res) {
res.render('index');
});
//NOT FOUND
app.use(function(req, res) {
res.type('text/plain');
res.status(404);
res.send('404 - Not Found');
});
//SERVER ERROR
app.use(function(err, req, res, next) {
console.error(err.stack);
res.type('plain/text');
res.status(500);
res.send('500 - Server Error');
});
app.listen(port, function() {
console.log('app running');
});