-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (23 loc) · 881 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
//import depencies
const express = require("express");
const exphbs = require("express-handlebars");
const router = require("./controllers/burgers_controller")
//Create Server
const server = express();
//Indicate server port
const PORT = process.env.PORT || 8080;
// Serve static content for the app from the "public" directory in the application directory.
server.use(express.static("public"));
// Parse request body as JSON
server.use(express.urlencoded({ extended: true }));
server.use(express.json());
//User handlebars main
server.engine("handlebars", exphbs({ defaultLayout: "main" }));
server.set("view engine", "handlebars");
//Use router for router handling
server.use(router);
//Start server listen
server.listen(PORT, ()=>{
// Log (server-side) when our server has started
console.log("Server listening on: http://localhost:" + PORT);
});//End server listen