koa hello world

来源:互联网 发布:淘宝怎么看店铺排名 编辑:程序博客网 时间:2024/06/06 13:12

1.升级node 到 11

2.npm install koa  安装koa

3.编写koa hello 代码 koaTest.js


var koa = require('koa');
var app = koa();
  
app.use(function *() {
    this.body = 'Hello world';
});


var server = app.listen(3000, function() {
    console.log('Koa is listening to http://localhost:3000');
});


4.执行 node --harmony  koaTest    (--harmony 是启用ECMAScript 6 )

5.访问http://localhost:3000/admin


页面显示 Hello 

参考文档:http://koajs.cn/




0 0
原创粉丝点击