Last active
October 7, 2022 13:50
-
-
Save ShaunSHamilton/62fdd7f75731600ed03aa1337250cf5b to your computer and use it in GitHub Desktop.
Advanced Node and Express - Set up a Template Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
require('dotenv').config(); | |
const express = require('express'); | |
const myDB = require('./connection'); | |
const fccTesting = require('./freeCodeCamp/fcctesting.js'); | |
const app = express(); | |
app.set('view engine', 'pug'); | |
app.set('views', './views/pug'); | |
fccTesting(app); // For fCC testing purposes | |
app.use('/public', express.static(process.cwd() + '/public')); | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
app.route('/').get((req, res) => { | |
// Change the response to render the Pug template | |
res.render('index'); | |
}); | |
const PORT = process.env.PORT || 3000; | |
app.listen(PORT, () => { | |
console.log(`Listening on port ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment