-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (24 loc) · 856 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
var express = require('express'),
exphbs = require('express-handlebars'),
bodyParser = require('body-parser'),
// mongoose = require('mongoose'),
http = require('http'),
request = require('request'),
routes= require('./routes');
// Create express instance
var app = express(),
port = process.env.PORT || 8080;
// Set handlebars as the template engine
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
app.use(bodyParser.json());
// Index route
app.get('/', routes.index);
// Individual blog post
app.get('/:slug', routes.blogpost);
// Set /public as static content dir
app.use('/', express.static(__dirname + '/public'));
// Start the server
var server = http.createServer(app).listen(port, function() {
console.log('Express server listening on port ' + port);
});