Nodejs Introduction (multiple articles combined) _javascript tips

Source: Internet
Author: User
Node.js is a set of JavaScript toolkits for writing high-performance Web servers, and a series of changes begin. Quite uniquely, Node.js will assume that you are running Linux or Mac OS X in a POSIX environment. If you are under Windows, then you need to install MinGW to get a POSIX-like environment. In node, HTTP is paramount. Node optimizes the creation of HTTP servers, so most of the examples and libraries you see on the Web are focused on the Internet (HTTP frameworks, template libraries, and so on).

First, go to http://nodejs.org to download the installation. My next version is 0.6.6. The installation is simple, the next step is OH.
My installation directory is C:\Program Files (x86) \nodejs.

First, HelloWorld
Create a new file in the Nodejs installation directory hello.js, knocking a line of code inside
Copy Code code as follows:

Console.log (' Hello, Nodejs. ');

Go to the command line console and go to the Nodejs directory to knock node Hello.js

The console outputs "Hello, Nodejs."
Second, the web version of the HelloWorld
Create a new http.js in the Nodejs installation directory with the following code

Copy Code code as follows:

var http = require ("http");
Http.createserver (function (request, response) {
Response.writehead ({"Content-type": "Text/html"});
Response.Write ("Hello world!");
Response.End ();
}). Listen (8000);

Start the service on the command line, knocking node Http.js

Then open the browser address bar input http://localhost:8000/, see the page output Hello world! was successful.

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.