1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| const Router = require('koa-router');
router.post('/getTxt', async (ctx) => { ctx.status = 200; ctx.body = 'abc'; });
app.use(router.routes());
app.use((ctx) => { ctx.status = 400; ctx.body = 'Bad Request'; }); app.use(router.allowedMethods());
const port = 3000; app.listen(port, () => { console.log(`应用运行在 http://localhost:${port}`); });
|