Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 979 Bytes

note.md

File metadata and controls

40 lines (25 loc) · 979 Bytes

这篇教程主要介绍koa2构建服务器,简单引用

本教程的版本:要格外注意版本号

image.png

案例:简单利用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

本片就结束了

推荐node项目工具