Skip to content

Instantly share code, notes, and snippets.

@camperbot
Forked from ShaunSHamilton/server.js
Last active December 5, 2022 05:52
Show Gist options
  • Save camperbot/4af125119ed36e6e6a8bb920db0c0871 to your computer and use it in GitHub Desktop.
Save camperbot/4af125119ed36e6e6a8bb920db0c0871 to your computer and use it in GitHub Desktop.
Advanced Node and Express - Use a Template Engine's Powers
'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');
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(process.cwd() + '/views/pug/index', { title: 'Hello', message: 'Please login' });
});
app.listen(process.env.PORT || 3000, () => {
console.log('Listening on port ' + process.env.PORT);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment