koa2系列教程,持續更新
這篇教程主要介紹koa2構建服務器,簡單引用
本教程的版本:要格外注意版本號
案例:簡單利用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/...
本片就結束了
推薦node項目工具
首發於微信公衆號:node前端
不妨關注一下