Creating a web server is easy with Node.js. You can build a web server with the HTTP or HTTPS modules that ship with Node.js. This video shows you how to create a server that serves plain text. Learn how to write headers to define the content type that is being served. Then, Alex shows you how to serve HTML text.
That callback handler is a function that we send to … both objects that are passed … to the callback handler for every request. … So the first thing we're going to take a look at … And this is where we'll send an http response … back to the user who made the request. … which means that this is a successful request. … And that tells the browser or whoever made the request … So we're just going to go ahead and … encode our response as plain text. … And the first response that we'll send back is Hello World. … I can send a string of plain text back to the user … who made the request. … Now before I run this I want to add a console.log … to let our users know that Web Server … is listening on Port 3000. … Great, so now I'll open up the terminal … and node server … and when I run this I see my console log. … And notice that this is an asynchronous module, … If I go over to the browser I can make those requests. … So I'm going to go ahead and kill this server. … So most of our responses aren't going to be text plain. …
- Making HTTP requests
- Building web and file servers
- Installing packages with npm
- Managing and linking global packages
- Working with Express, the web server framework
- Handling POST and DELETE requests
- Creating WebSockets
- Testing and debugging Node.js code
Skill Level Advanced
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
Work with VSCode1m 59s
1. The HTTP Module
3. Web Servers
5. Node.js Testing
6. Automation and Deployment
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.