1.将learn_koa_url文件夹复制一份命名为(learn_koa_url1)
2.在(learn_koa_url1)下新建两个文件夹
(1).vscode --> launch.json
(2)controllers -- > index.js和login.js
最后目录结构如下
3.整理后的代码如下
(1)hello.js的代码
var fn_hello = async(ctx, next) => {
var name = ctx.params.name;
ctx.response.body = `<h1>Hello,${name}!</h1>`
};
module.exports = {
'GET/hello/:name': fn_hello,
}
(2)index.js的代码如下
var fn_index = async (ctx, next) => {
ctx.response.body = `<h1>Index</h1>
<form action="/signin" method="post">
<p>Name:<input name="nam