-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (24 loc) · 939 Bytes
/
Copy pathserver.js
File metadata and controls
25 lines (24 loc) · 939 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
// Loads my express module
const express = require("express");
// Sets the port for the application
const PORT = process.env.PORT || 3000;
// Creates my express application.
const app = express();
// Set Handlebars
var expressHandleBars = require("express-handlebars");
// Import routes to the server.
const routes = require("./controllers/burgers_controller.js");
// App will serve static content from the "public" folder
app.use(express.static("public"));
// Parse application body as JSON
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.engine("handlebars", expressHandleBars({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// App will serve the routes
app.use(routes);
// Start our server so that it can begin listening to client requests.
app.listen(PORT, function () {
// Log (server-side) when our server has started
console.log("Server is listening at localhost:" + PORT);
});