-
-
Save azamsharp/892d684de0f41936787d96a14a33fce2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const express = require('express') | |
const app = express() | |
const mustacheExpress = require('mustache-express') | |
// setting up Express to use Mustache Express as template pages | |
app.engine('mustache',mustacheExpress()) | |
// the pages are located in views directory | |
app.set('views', './views') | |
// extension will be .mustache | |
app.set('view engine','mustache') | |
app.get('/',(req,res) => { | |
res.render('index') | |
}) | |
// localhost:3000/ | |
app.get('/hello',(req,res) => { | |
res.render('hello',{bookName: "Introduction to JavaScript", isbn: "123456"}) // display the hello.mustache page | |
}) | |
app.listen(3000,() => { | |
console.log('Server is running...') | |
}) |
This file contains hidden or 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
<html> | |
<head> | |
<title>{{bookName}}</title> | |
</head> | |
<body> | |
<h1>Welcome to Amazon</h1> | |
<h1>The name of the book is {{bookName}}</h1> | |
ISBN {{isbn}} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment