(file: string)
| 93 | const pathstr = url.pathname; |
| 94 | |
| 95 | async function sendFile(file: string) { |
| 96 | try { |
| 97 | const f = await fs.readFile(file); |
| 98 | res.writeHead(200, {"Content-Type": guessMime(file)}); |
| 99 | res.write(f); |
| 100 | res.end(); |
| 101 | } catch { |
| 102 | res.writeHead(404, {"Content-Type": "text/html"}); |
| 103 | res.write("Uh, this ain't supposed to happen"); |
| 104 | res.end(); |
| 105 | } |
| 106 | } |
| 107 | if (pathstr === "/") { |
| 108 | sendFile(path.join(__dirname, "webpage", "index.html")); |
| 109 | return; |