一.为Express添加about路由 1.新建js文件,about.js 2.打开about.js,并输入以下代码: var express=require('express'); var router=express.Router(); router.get('/',function(req,res,next){ res.send('Hello from the about route!'); }); module.exports=router; 2.打开app.js,然后输入以下代码: v…
let express = require('express'); let app = new express(); let bodyParser = require('body-parser'); let ejs = require('ejs'); // 配置模板引擎 app.set('views','./ejs'); app.set('view engine','ejs'); app.engine('ejs',ejs.__express); // 引入bodyParser中间件(内置中间件)…
var http = require("http"); var url = require("url"); var ejs = require("ejs"); var querystring = require("querystring"); var server = http.createServer(function(req,res){ res.writeHead(200,{"content-type"…