Using Ejs's demo fifth in node. js

Source: Internet
Author: User

Let's start by explaining my project's directory deconstruction:

The project is rendered in the Index.js page, to use the Index.ejs, the first reference must be the module:

var express = require (' Express '); var router = Express. Router (); var fs = require ("FS"); var http = require ("http");

Renders the data inside the Index.json to the Index.ejs page, and renders the Index.ejs page when the local http://localhost:3000/is accessed and uses it.

function (req, res, next) {  //  Async Read  function  (err, data) {    if  (Err) {      return  console.error (err);    }    Res.render (' index ', Json.parse (data.tostring ()));     // fs.close ();   });});

After starting the project, the content of the Index.ejs template is accessed through http://localhost:3000/, and everything here is based on node. JS's Frame Express.

may be accessed through the above content will jump to index.html "public inside the index.html", you can see above I was carried out processing, the index.html to delete processing, if you have a better way to deal with, I hope you can leave a message to tell me.

Using Ejs's demo fifth in node. js

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.