-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (22 loc) · 896 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
const express = require('express');
// PORT
const PORT = process.env.PORT || 3030;
// Create an instance of the express app
const app = express();
// Serve static content for the app from the "public" directory in the application directory
// app.use(express.static("public"));
app.use(express.static(__dirname + '/public'));
// Set Express app to handle data parsing
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Set Handlebars
const exphbs = require('express-handlebars');
app.engine('handlebars', exphbs({ defaultsLayout: 'main' }));
app.set('view engine', 'handlebars');
// Import routes and give the server access to them
const routes = require("./controllers/icecream_controller.js");
app.use(routes);
// Start server to listen to client requests
app.listen(PORT, function () {
console.log("Server listening on: http://localhost:" + PORT);
});