You are previewing Node Web Development.

Node Web Development

Cover of Node Web Development by David Herron Published by Packt Publishing
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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.