-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
27 lines (19 loc) · 857 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
const express = require("express");
const methodOverride = require("method-override");
const bodyParser = require("body-parser");
var app = express();
var port = process.env.PORT || 3000;
// Use the express.static middleware to serve static content for the app from the "public" directory in the application directory.
app.use(express.static("public"));
// Sets up the Express app to handle data parsing
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
//override with POST having ?_method = PUT
app.use(methodOverride('_method'));//HTML5 Method only have POST and GET
var exphbs = require("express-handlebars");
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
require('./routes')(app);
app.listen(port, function() {
console.log("Listening on PORT " + port);
});