// 导入koa,和koa 1.x不同,在koa2中,我们导入的是一个class,因此用大写的Koa表示:
const Koa = require('koa');
// 创建一个Koa对象表示web app本身:
const app = new Koa();
// 对于任何请求,app将调用该异步函数处理请求:
app.use(async (ctx, next) => {
await next();
ctx.response.type = 'text/html';
ctx.response.body = '<h1>Hello, koa2!</h1>';
});
// 在端口3000监听:
app.listen(3000);
console.log('app started at port 3000...');
相关文章
- 09-26A New Start
- 09-26IAR EWARM __iar_program_start, __iar_data_init3, __iar_copy_init3, __iar_zero_init3
- 09-26How to unhighlight new applications in start menu
- 09-26Kick Start 2019 Round D
- 09-26RobotFramework RobotFramework官方demo Quick Start Guide浅析
- 09-26Docker安装完成后启动报错:Failed to start Docker Application Container Engine
- 09-26{RuntimeError} An attempt has been made to start a new process before the current process has finish
- 09-26start all over again
- 09-26解决 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
- 09-26RocketMq发送消息出现com.alibaba.rocketmq.client.exception.MQBrokerException: CODE: 2 DESC: [TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: 201ms, size of queue: 1