- JavaScript
- Intermediate
About this Course
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
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.
5 stepsHandling 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.
4 stepsCreating 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.
5 stepsHTTP 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.
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.
Teacher
-
Andrew Chalkley
I'm an alien, I'm a legal alien, I'm an Englishman in Portland. All of my professional life I've worked with computers online. I'm a polyglot programmer and like using the right tools for the job. In my spare time I enjoy spending time with my family and when I get chance, sticking opponents in Halo 4.