Skip to content

Instantly share code, notes, and snippets.

@NikhilNanjappa
Created February 12, 2022 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikhilNanjappa/a22b815741da8bc079caa2360e16e012 to your computer and use it in GitHub Desktop.
Save NikhilNanjappa/a22b815741da8bc079caa2360e16e012 to your computer and use it in GitHub Desktop.
GDS Demo complete app.js
const path = require('path')
const nunjucks = require('nunjucks')
const express = require('express')
const app = express()
const port = 3004
nunjucks.configure([
path.join(__dirname, 'node_modules/govuk-frontend/'),
path.join(__dirname, 'app/views/')
], {
autoescape: true,
express: app,
noCache: true,
watch: true
})
app.set('view engine', 'html')
app.use(express.static(path.join(__dirname, 'public')))
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/assets')))
app.use('/govuk-frontend', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk')))
app.get('/', (req, res) => {
return res.render('layout')
})
// Run the application
app.listen(port, () => {
console.log(`App running on => http://localhost:${port}`)
}).on(('error'), (err) => {
if (err.errno === 'EADDRINUSE') {
console.log(`----- Port ${port} is busy. Please use another port.`)
} else {
console.log(err)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment