Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Build a Simple Dynamic Site with Node.js Course (How To)

via Treehouse

Overview

Node.js is a versatile platform for building all sorts of applications. In this course, we're going to make a dynamic website that displays a Treehouse student's profile information by creating a server that will dynamically generate content, handle URLs, read from files and build a simple template engine.

What you'll learn

  • Creating an HTTP Server
  • Reading Files
  • Handling HTTP Methods
  • Customizing HTTP Headers

Syllabus

Creating a Simple Server in Node.js

Node.js has awesome APIs that allow you to build all types of applications. Traditionally you'd need to install a server like Apache or NGINX if you wanted to run a static or dynamic website – but Node.js allows you to write your own web server with a simple API call.

Chevron 5 steps
  • Overview

    1:00

  • HTTP Servers

    2:01

  • Preparing & Planning

    12:09

  • Creating a Simple Server

    10:56

  • HTTP Server Review

    8 questions

Handling Routes in Node.js

When you type in a web address a request is sent to a server. After a domain name, there's a forward slash and then a path to a resource on the server. Sometimes, this is called a route. In this stage, we'll take a look at how to programmatically handle routes in Node.js.

Chevron 4 steps
  • Home Route

    5:40

  • User Route

    6:01

  • Populating User Information

    9:29

  • Handling Routes Review

    2 objectives

Creating a Basic Template Engine in Node.js

A lot of our HTML contains the same content so we're going to use a principle called DRY, or Don't Repeat Yourself and separate out the unique content in separate files. We'll also write some code that combines all of this content and put in dynamic values – in other words, we're creating a Template Engine.

Chevron 5 steps
  • Making Our Views DRY

    6:34

  • Reading from Files

    15:33

  • Reading Files Review

    4 questions

  • Binding Values

    7:10

  • A Simple Merge Utility

    1 objective

HTTP Methods and Headers

Creating your own HTTP servers and web applications requires you to know some of the ins-and-outs of how an HTTP client and HTTP server talk to each other. In this stage we'll take a look at some HTTP headers and HTTP methods.

Chevron 5 steps
  • Sending Content Type Headers in Node.js

    4:36

  • Dealing with the POST Body

    11:24

  • Redirection Headers in Node.js

    4:10

  • Perfection Suggestions

    1:18

  • HTTP Methods and Headers Review

    8 questions

  • Extra Credit

    Create a Lorem Ipsum generator site in Node.js. Have a web form that asks for a number of words, sentences or paragraphs to generate placeholder text. Have it write to a response in a template. An example of a Lorem Ipsum generator is at http://www.lipsum.com.

Reviews

Start your review of Build a Simple Dynamic Site with Node.js Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.