In this chapter we look at the Content Type from the client to be able to separate requests to the server as either requests for a file or requests for a function to be called on the server. In this case we separate out the requests and create an echo server to return the arguments back to the client.
In this article we go through the process of parsing the form data of from data that we’ve uploaded to the server. When it comes to parsing, we need to find the text pattern used for separating boundaries and read everything in between to extract the files.
In this chapter we take the raw POST data that we uploaded in the previous chapter and parse it to JSON data so that we can handle it easier. In the next chapter we will change our focus to working with JSON data in a more direct fashion.
In this chapter of the Nodejs be continue to expand on the sending data to the server. In this example we create a form on the client side, and send the form via a POST request to the server, to unpack the body contents and return them to the client, so we can see how form data is encoded when sent to the server.
Now that we’ve started to make calls to the server, in this chapter we go over how to upload an image. This consists of taking a file from the client and uploaded it as an http request, and reading the request body on the server and writing the data to a file.
In the previous chapter we wrote a simple Ajax call where we returned the simple expression “Hello World”. In this chapter we add on to the previous example by writing a simple echo function where we provide a Name as a parameter to the server, and have the server reply with “Hello Name”.
In the previous chapter we learned how to create modules to simplify our code. Now that he have a basic grasp on how to serve static files from Nodejs, in this chapter we switch to more learning how to create a more dynamic application server where we handle both static files, and Ajax requests from the client. We start with a simple “hello world” example.
In the previous chapter, we implemented the functionality of a directory index where all of the files in a directory would be listed. As a result of that our code started to get long and messy, so in this chapter we introduce modules to implement specific functionality to organize our code.
In this chapter of the Nodejs book, we implement the functionality of a directory listing for a file server. In the case that the path of a folder is requested and no index.html exists in that directory, then we read the list of all of the files in the directory, and render a page to be returned to the client.
This this chapter of our Nodejs “book” we create a simple file server, that will interpret requests to the server as file paths. The server will then search through the public directory for static files and return them to the http client if they are found.