deno.js 328 B

123456789101112
  1. import { serveFile } from "https://deno.land/std/http/file_server.ts";
  2. async function handler(req){
  3. let url = req.url;
  4. let iSlash = url.indexOf('/',11);
  5. let path = url.substring(iSlash);
  6. if(path.endsWith('/'))
  7. path = path + 'index.html';
  8. return await serveFile(req, `${Deno.cwd()}`+path);
  9. };
  10. Deno.serve(handler);