-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (25 loc) · 840 Bytes
/
Copy pathapp.js
File metadata and controls
32 lines (25 loc) · 840 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
30
31
32
const express = require('express');
const cons = require('consolidate');
const path = require('path');
const bodyParser = require('body-parser');
const index = require('./routes/index');
const app = express();
// View engine setup
app.engine('html', cons.swig)
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'html');
// Enable the body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Use the index.js file to serve http requests
app.use('/', index);
// Set the listening port
const PORT = 3000;
// Serve the index.html page when home page is requested
app.get('/', (req,res) => {
res.render('index.html')
});
// Listen on the defined port and log the port to the console
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}...`);
});