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