[A dangerous] 1, node. js tries to install & run the first HelloWorld

Source: Internet
Author: User

Official website:https://nodejs.org/

Introduction: Node.js®is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. node. JS uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive R Eal-time applications that run across distributed devices.

keywords: background language, Chrome's JavaScript runtime, Event-driven, non-blocking I/O model

installation mode:windows on the official website, click the Install button can be installed directly

The first of the HelloWorld: (a Web server)

1. Create a new Example.js file and enter the following code:

1 var http = require (' http '); 2 http.createserver (function  (req, res) {3   res.writehead (200, {') Content-type ': ' Text/plain '}); 4   Res.end (' Hello world\n '); 5 }). Listen (1337, ' 127.0.0.1 '); 6 console.log (' Server running at http://127.0.0.1:1337/');

2, cmd to open the command line, go to the above new file directory, enter: Node Example.js (after the server startup effect is as follows)

3, the above said this is a Web server, so in the browser can be directly input http://127.0.0.1:1337/, you will see Hello World interface:

Description: from a simple example above, you must have seen the advantage of node. js, which is to build a Web server with just a few lines of code, which would allow the JSP to do more code.

extension: in the homepage of the install below there is an API Docs button, if you want to more detailed play node. js can start from here, at the same time there are more books on the market ~

[A dangerous] 1, node. js tries to install & run the first HelloWorld

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.