router .get("/", (context) => { context.response.body = "Hello world!"; })
app.use((ctx) => {// Will throw a 500 on every request. ctx.throw(500);});
export default async (context:any,next:Function)=>{//塞點內容進來}
const data = Deno.readFileSync(_static+filename);
let {response,request} = context;response.body = data;
app/utils/static.ts
import { Application } from "https://deno.land/x/oak/mod.ts";import _static from "./utils/static.ts";const app = new Application();app.use(_static);console.log('start at point :8000');app.listen({ port: 8000 });
deno run --allow-net --allow-read index.ts
const run = ()=>{ return Deno.run({ cmd: ["deno", "run","--allow-net","--allow-read","index.ts"], cwd:"app", }); }let _porcess = run();const watcher = Deno.watchFs("./app");for await (const event of watcher) { console.log('kill proceess'); _porcess.close(); console.log('restart'); _porcess= run();}
deno run --allow-net --allow-read index.ts
deno run --allow-net --allow-read --allow-run launch.ts
import { Application } from "https://deno.land/x/oak/mod.ts";
import * as oak from 'https://deno.land/x/oak/mod.ts';export { oak}