MCPcopy Create free account
hub / github.com/MathMan05/Fermi / sendFile

Function sendFile

src/index.ts:95–106  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

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;

Callers 1

index.tsFile · 0.85

Calls 2

guessMimeFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected