Start the Nodejs service

Source: Internet
Author: User

VS Code Intermediate Creation

1. Settings.json

{"Git.ignorelimitwarning":true}

2.

1. NPM Init installs Pageage.json 2.  NPM Install Jqurey Bootstrap 3. Install NPM install-g cnpm--registry=https://registry.npm.taobao.org4. Node HTTP service 1. Require (' HTTP ')//introduced 2. Create HTTP Service 3. Receives the Send response request HTTP. Createserver response.writehead (200,{' content-type ': ' Text/plain '})//Request header content-type:text/html//with HTM L returnText/plain//Return as-isText/joinText/xml

3.

//1. Require (' http ')varhttp= require(' http ')varPort= 8000 //2. Creating an HTTP service from an HTTP modulevarNodeserver=http.Createserver(function(Request,Response) {//Send HTTP header //HTTP Status value: 200 (Success) 400 500 401 402 403 ... 502 errors on the service sideResponse.Writehead( $, {' Content-type ':' Text/plain;charset=utf-8 '})//content is Text/plain //Send the response data to the clientResponse.End(' Hello first Nodejs ')}) Nodeserver.Listen(Port,' localhost ',function(Err) {if(ERR)ThrowErr//Service creation failed, burst error Console.Log(' Service created successfully! ')})

4. Start

PS d:\nodejs\node-master\http> Node Index01.js service created successfully!

5. Http://localhost:8000/

Note If there is a garbled

Pasting

Response.Writehead( $, {' Content-type ':' Text/plain;charset=utf-8 '})

Start the Nodejs service

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.