-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (20 loc) · 764 Bytes
/
server.js
File metadata and controls
29 lines (20 loc) · 764 Bytes
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
var express = require('express');
var app = express();
//Serve up static assets from public
app.use(express.static('public'));
var PORT = process.env.PORT || 8080;
// Parse application body as JSON
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Use Handlebars
var exphbs = require('express-handlebars');
app.engine('handlebars', exphbs ({defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
// Import routes and give server access to them
var routes = require('./controllers/controller.js');
app.use(routes);
// Start the server so that it begins listening to client requests.
app.listen(PORT, function() {
//log when the server has started
console.log('Server listening on http://localhost:' + PORT);
});