Koa 最小示例
另请参见带路由器和 Body 解析器的最小 Koa.JS 示例
koa-example.js
const Koa = require('koa');
const app = new Koa();
app.use(async ctx => {
ctx.body = {status: 'success'};
});
app.listen(8080);安装(请参见此之前的文章了解安装 NodeJS 和 NPM 的指南):
install-and_run.sh
npm install --save koa
node index.js然后转到 http://localhost:8080/ 查看测试页面。
Check out similar posts by category:
Javascript
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow