"Front node. JS Framework" node. JS Framework Express

Source: Internet
Author: User

Server.js/*The following code will be explained in detail below.*/varExpress = require (' Express ');//used to introduce express modulesvarApp = Express ();//Express Instance ObjectApp.set (' Port ', Process.env.PORT | | 3000);varFavicon = require (' Serve-favicon '));//Server.jsvarTOUSD = require ('./routes/tousd.js '));//App.use (TOUSD.AAA);//Console.log (TOUSD.AAA ())//Console.log (TOUSD.BBB ())App.use (TOUSD.BBB);//set Port toApp.get ('/',function(req, res) {//set the route of the home page with '/' representationRes.send (' Ritsu Yan6668978989474561212565645 ')})//The middleware attached to/user/:id, any request to/user/:id will execute itApp.use ('/user/:id ',function(req, res, next) {Console.log (' Request Type: ', Req.method); Next ();}); App.get ('/about ',function(req, res) {//set the route of the About page with '/about ' representationRes.send (' The node course ')}) App.use (function(req, res, next) {//set 404 PageRes.status (404); Res.send (' 404-not Found ')}) App.listen (App.get (' Port '),function() {//Listening Port If a user enters a page to send a request we output the following statementConsole.log (' Express started on Port 3000 ')})

Portal: http://www.runoob.com/nodejs/nodejs-express-framework.html

"Front node. JS Framework" node. JS Framework Express

Related Article

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.