Use node JS to create a server upgrade version

Source: Internet
Author: User
Tags node server

1. Prepare a folder for the project

2. Create a server.js file under the root directory

3. The file code is as follows

var http = require ("http");

Http.createserver (function (request,response) {
Response.writehead (200,{' content-type ': ' Text/plain ');
Response.End ("Hello world\n")
}). Listen (8080);

Console.log ("Server running at http://127.0.0.1:8080/")

4. Open the project directory with the command line execute the node server.js command

5. Open the corresponding port in the browser to see what we are writing

Varhttp= Require(' HTTP ');http.Createserver(function (Request,Response) {Send HTTP HeaderHTTP Status value: 200:okContent Type: Text/plainResponse.Writehead(200, { ' Content-type ' Span class= "pun" >:  ' text/plain ' }); //send response data "Hello World"      Response. ' Hello world\n ' listen (8888//terminal prints the following information console. ( ' Server running at http://127.0.0.1:8888/'    

Use node JS to create a server upgrade

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.