const Koa = require('koa'); const app = new Koa(); const static = require('koa-static') app.use(static("./view/dist")) const { koaBody } = require('koa-body'); const KoaSSEStream = require('koa-sse-stream'); app.use(koaBody()); app.use(async (ctx, next) => { ctx.set('Access-Control-Allow-Origin', '*'); ctx.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With'); ctx.set('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); if (ctx.method == 'OPTIONS') { ctx.body = 200; } else { await next(); } }); const index = require("./router/index.js") app.use(index.routes()).use(index.allowedMethods()) const videoInfo = require("./router/videoInfo.js"); app.use(videoInfo.routes()).use(videoInfo.allowedMethods()) app.listen(3050, "0.0.0.0"); // 引入定时检测更新 require("./util/Video/Update.js") console.log("link: http://127.0.0.1:3050")