Skip to content

Instantly share code, notes, and snippets.

@code-for-coffee
Created September 1, 2015 17:55
Show Gist options
  • Save code-for-coffee/35b3a27efc9cee3f7529 to your computer and use it in GitHub Desktop.
Save code-for-coffee/35b3a27efc9cee3f7529 to your computer and use it in GitHub Desktop.
Intro to Node Lab

GeneralAssemb.ly

Building Servers with Node

###WDI Darth Vader


Lab

We're going to continue building a few basic servers using Node.js. We want to demonstrate that we can serve HTML and JSON using Node anf the http module.


Problem #1

  1. Create a new directory and call it node_people
  2. Change into that directory.
  3. Run npm init to create your package.json
  4. In your index.js, create a server that returns JSON.
  5. The JSON you should return will have the following string attributes:
  • Name
  • Hobby
  • Colour
  • FavouriteBook

Problem #2

  1. Create a new directory and call it node_about
  2. Change into that directory.
  3. Run npm init to create your package.json
  4. In your index.js, create a server that returns a basic HTML page about yourself.
  5. The HTML should return with the following tags:
  • html
  • body
  • h1
  • h2
  • p

Problem #3

  1. Create a new directory and call it node_turtles
  2. Change into that directory.
  3. Run npm init to create your package.json
  4. In your index.js, create a server that returns JSON about a Teenage Mutant Ninja Turtle.
  5. The JSON you should return will have the following attributes:
  • Name
  • Weapon
  • Colour
  • FavouriteFood
  • Age
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment