const handler = async (req: Request): Promise<Response> => {
const url = new URL(req.url);
const filePath: string = "./client" + (url.pathname === "/" ? "/index.html" : url.pathname);
try {
const file = await Deno.open(filePath, {read: true});
const readableStream = file.readable;
return new Response(readableStream, {
status: 200,
})
} catch (_error) {
return new Response(`GET ${filePath}`, {status: 404});
}
};
const handler = async (req: Request): Promise<Response> => {
const url = new URL(req.url);
const filePath: string = "./client" + (url.pathname === "/" ? "/index.html" : url.pathname);
try {
const file = await Deno.open(filePath, {read: true});
const readableStream = file.readable;
return new Response(readableStream, {
status: 200,
})
} catch (_error) {
return new Response(`GET ${filePath}`, {status: 404});
}
};