这篇教程主要介绍koa2构建服务器,简单引用
本教程的版本:要格外注意版本号
代码
// index.js
const Koa = require('koa')
const app = new Koa()
app.use(async (ctx) => {
ctx.body = 'hello world'
})
app.listen(3000)
console.log('localhost:3000')
利用node index.js
就可以启动了,在浏览器中输入localhost:3000
源码地址:https://github.com/xiaqijian/koa2-lessons/tree/master/lesson1
本片就结束了