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!