Nodejs beginners and simple web cases

Source: Internet
Author: User

I'm using the window system, and the rest of the system should be similar.

1. Download

https://nodejs.org/en/

Just click on the latest version to download.

2. Installation

3. Testing

Open cmd command line, input node directly and enter

Type Console.log ("hello,world!");

View Output Results

hello,world! undefined

4. Create a working directory

Find a system disk, create a workspace\nodejs\

5. Create a simple Web project

Create Httpdemo/test.js

Write the following code:

var http = require ("http"); http.createserver(function(req, res) {    Res.writehead ( {"Content-type": "Text/html"});    Res.write (");    Res.end ("<p>game over Hhhhh</p>");}). Listen (8089); Console.log ("HTTP server is listening at Port 8089.");

Then start:

CMD go to file directory input: node test.js

Enter

Then enter it in the browser: http://localhost:8089/

If you can see the output, it indicates success.

Nodejs beginners and simple web cases

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.