node. JS Server Rationale

Source: Internet
Author: User
Tags response code

This article and everyone to share is the node. JS Server principle related content, come together to look at it, hope to be helpful to everybody.

  What are the requirements for Web application setup?

  Web application, it requires a client. A server is also required. The client side, do not need us to develop, we directly through the browser can be achieved. And the service side needs our own development. We all know that we open the browser, for example, we visit the Wheat Academy. After we have opened this site, the site can display a corresponding page. The bottom of this page, it should be some HTML code and CSS style + our js The dynamic effects that make up our page. These things, we want to show through the client browser, then this server first to show us this data. Description The server has a program that specifically writes this text to me to help me achieve it.

  How does this program come true?

When we were learning http in front of this module, we said in this module that this http can create a server.

This server, it has a function, this function can receive the user request, and can be requested by the corresponding user, then we can write all the response code into the response object.

Is it possible to respond to the past? We should not splice this string here.

It is read from the file. Read from the file, we think about it, we develop this program ourselves, it read the file, read our files? Read Our HTML file, read our css file, read our js text, or be a picture file.

These files all require code to read. And after reading, but also to respond to the client side, the browser can be loaded out, see. To do so, we have to develop such a program every time we request to read the file and determine what path the user is requesting. Do we have to develop this stuff every time? At this time, we can write a piece of code, these read static files are all packaged together. As long as it is requesting a static file, we can load the static file from this code by moving it. Then write it to the browser of this client. We develop this code ourselves, in fact, it is a simple server for us.

It can read our static files directly from the local server and write them to the browser.

in fact, this server in addition to reading these static files, it also has a lot of features, then these functions, such as parsing URLs and validating, response to static files and so on. As long as the server has these features, for our developers, as long as the installation of this server, we just need to develop our corresponding components on the line. Develop our static pages, develop our CSS, develop our JS, develop our corresponding business component logic.

write these code, and this parse request parameter, verify a series of tasks, such as URL request paths, are given to our servers for execution.

So, we just need to focus on writing the code we need to write, without needing to focus on how our code should respond to the client and how to get the browser to receive it. These are all things that the server is doing.

original link:http://www.maiziedu.com/wiki/nodejs/server/

node. JS Server Rationale

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.