const Router = require('koa-router');
let router = new Router();
router.get('/', async (ctx)=>{ctx.body = '用户操作首页'
})
路由模块化
在appApi下面创建需要模块化的文件
如:home.js、user.js
const Router = reuiqre('koa-router');
let router = new Router();
router.get('/home', async (ctx)=>{ctx.body = 'home'
})module.exports = router
导入
/service/index.js
const Koa = require('koa');
const app = new Koa()
const Router = require('koa-router');
let home = require('./appApi/.home.js');
let router = new Router();
router.use('/user', user.routes());app.use(router.routes());
app.use(router.allowedMethods());
while True:a int(input(摄氏度转换为华氏温度请按1\n华氏温度转化为摄氏温度请按2\n))if a 1:celsius float(input(输入摄氏温度:))fahreaheit (celsius 1.8) 32 # f c9/532print({:.2f}摄氏温度转为华氏温度为{:.2f}.format(celsius, fahreaheit))elif a …