O'Reilly logo

Node Web Development by David Herron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the Math Wizard with Node (no frameworks)

We're going to start by crawling, to appreciate what the web frameworks are doing for us. Crawling means starting with Node's core package, the HTTP Server object.

The Math Wizard, like any web application, has multiple pages, each with its own URL. Each page has a few common elements (the general page structure and the navigation bar) and per-page content unique to each page. In the Math Wizard the URLs are as follows:

  • /: For the wizard's home page
  • /square: To calculate the square of a number
  • /mult: To multiply two numbers
  • /factorial: To calculate the factorial of a number
  • /fibonacci: To calculate fibonacci numbers

To get started create a directory to hold the source code:

$ mkdir chap04

Routing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required