node. JS Getting Started

Source: Internet
Author: User

Node installation is not said, the process see http://www.runoob.com/nodejs/nodejs-install-setup.html. Directly to make a simple Web server

First enter and save a JS code to the installation directory under the Nodejs folder, as follows:

varHTTP = require ("http"); function Process_request (req,res) {varBODY ='First web server\n'; varContent_length =body.length; Res.writehead ( $,{        'content_length': Content_length,'Content_Type':'Text/plain'    }); Res.end (body);}vars =Http.createserver (process_request); S.listen (8080);

Then the CMD is entered as follows (this way to switch to the Nodejs directory):

Finally open the localhost:8080 with the local browser, you can see the response code

node. JS Getting Started

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.