In these examples, we establish the basic framework for what will become the Meadowlark Travel website, served by Express and templated with Handlebars.
All of the examples in this chapter have Node module dependencies (express
and express-handlebars
). These dependencies are listed in the package.json file. However, when you first clone this repo, you won't have them installed (package.json is simply a manifest). To install them, simply run:
npm install
Minimal example; uses Express, but doesn't do very much. To run:
node 00-meadowlark
Then visit http://localhost:3000 in your browser.
This example adds basic routing, for the home page and the "About" page. To run:
node 01-meadowlark
Then try the following URLs:
Example two uses Handlebars templates (views/*.handlebars) and a layout file (views/layouts/main.handlebars), as well as express.static
to serve static files (like images) from the public directory. To run:
node 02-meadowlark
Then try the following URLs:
This example (not referenced in the book, but corresponding to the section "Dynamic Content in Views") demonstrates a very simple "fortune cookie" example on the about page (see 03-meadowlark.js and views/about.handlebars). To run:
node 03-meadowlark
Then try the following URLs: