Nodejs uses express to create a simple web application, nodejsexpress

Source: Internet
Author: User

Nodejs uses express to create a simple web application, nodejsexpress

When initializing a project, Express needs to specify the template engine. By default, Jade and ejs are supported.

Here we use the ejs template engine: (for introduction to ejs, You can first get a rough idea from the encyclopedia)
EJS is a Javascript template library used to generate HTML strings from JSON data.

When using express to create a website, use the ejs template engine to create a basic website structure. The following is used in the current directory: the express-t ejs sophiehui command creates a subdirectory of sophiehui in the current directory, as shown in the following figure:

The last line prompts us to install the dependency, so next we will go to the sophiehui directory to install the dependency: npm install (The npm install function without parameters is to check the package. json file in the current directory and automatically install all specified dependencies.)

Wait until the execution ends.

View your first express application: npm start (use node app in the Command Prompt window. js), and then access http: // localhost: 3000/to see the effect of 2.

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.