-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ts
33 lines (32 loc) · 991 Bytes
/
run.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const indexHtml = Deno.readFileSync("./dist/index.html");
const mainJs = Deno.readFileSync("./dist/main.js");
const mainCss = Deno.readFileSync("./dist/main.css");
const faviconSvg = Deno.readFileSync("./dist/favicon.svg");
Deno.serve({ port: 8302 }, (req) => {
const url = new URL(req.url);
switch (url.pathname) {
case "/main.js": {
return new Response(mainJs, {
headers: { "content-type": "text/javascript; charset=UTF-8" },
});
}
case "/":
case "/index.html": {
return new Response(indexHtml, {
headers: { "content-type": "text/html; charset=UTF-8" },
});
}
case "/main.css": {
return new Response(mainCss, {
headers: { "content-type": "text/css; charset=utf-8" },
});
}
case "/favicon.svg": {
return new Response(faviconSvg, {
headers: { "content-type": "image/svg+xml; charset=utf-8" },
});
}
default:
return new Response(null, { status: 404 });
}
});