Express Development Example (1)--hello,world!

Source: Internet
Author: User
Tags install node

Express is the most commonly used base module in NODEJS development. The Nodejs itself has an HTTP module, but it's not easy to use, so someone developed the Express module on that basis.

What is Express

Express offers a rich routing capability as well as a template engine.

User-friendly definition of complex application scenarios.

Preparation before development

First need to install Nodejs, there are many tutorials on the internet, do not build wheels.

After installing Nodejs, use the NODE-V command to detect the version of node.

Node-v

NPM can install modules in node and use the NPM-V command to detect NPM versions. (After you install node, you bring NPM)

Npm-v

Then you need to install Express, open the command line in the development directory, enter

NPM Install Express

This is the Node_modules directory that will be created in the current directory.

If you want to install global Express, you can use the command

NPM Install-g Express
Hello,world

In the MyApp directory, create the Index.js:

var express = require (' Express '); // introducing the Express module var app = Express (); // Create an app // defining routes, returning strings function (req, res) {  res.send (' Hello World ');}); App.listen (+); //Bound listening port console.log (' Express started on Port 3000 '); //Output monitoring information

Then in the current directory, run

Node Index

Visit localhost:3000 to see Hello,world's Web page.

Reference

"1" express official Github:https://github.com/strongloop/express

Express Development Example (1)--hello,world!

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.