Skip to content

Latest commit

 

History

History
65 lines (41 loc) · 1.74 KB

File metadata and controls

65 lines (41 loc) · 1.74 KB

Chapter 3 Examples - Web Development with Node and Express, 2nd Edition

Meadowlark Travel Website

In these examples, we establish the basic framework for what will become the Meadowlark Travel website, served by Express and templated with Handlebars.

Setup

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

Example 0

Minimal example; uses Express, but doesn't do very much. To run:

node 00-meadowlark

Then visit http://localhost:3000 in your browser.

Example 1

This example adds basic routing, for the home page and the "About" page. To run:

node 01-meadowlark

Then try the following URLs:

Example 2

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:

Example 3

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: