Cover by David Herron

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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 ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required