安装
npm i koa
使用
const Koa = require("koa")cosnt app = new Koa()app.use(asnc ctx => {ctx.body = "hello world"//运行后会打印在浏览器上})//监听一个接口app.listen(3000,()=> {console.log("服务器已经启动")})
先启动服务, node …./a.js(文件想读路径地址),启动成功后会显示 “服务器已经启动”
然后,在浏览器地址栏中输入:http://localhost:3000
