node. js First Knowledge 01

Source: Internet
Author: User

1. For node. JS installation Here is not too much to introduce, after the successful installation, you can use the CMD input node-v to view the version number of node,

2. Start our Hello world, enter the owning folder via CMD, input node 01.js

 // require means introduction package  var  http = require ("http"  //  Create service  var  server = http.createserver (function   (req,res) { //    req represents the request, and RES represents the response  //  res.writehead (200,{" Content-type ":" Text/html;charset=utf-8    "}); Res.end ( "Haha, this is my first page" + (1+2+3) + "s"  //  running server, listening port number 3000, port number can be changed to  Server.listen ("127.0.0.1"); 

3. Then enter 127.0.0.1:3000 in the browser window and you will see the following screen

Attached to Node's official website, you can see all the methods and properties Https://nodejs.org/docs/latest-v7.x/api/http.html#http_response_write_chunk_encoding_callback

node. js First Knowledge 01

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.