Ha! Thank you. I used the forum search for "openfile" without results ;(
Here is one solution to help other users.
It fixes the heap leak, but still eventually fails to open the file.
var f = E.openFile(a.pathname, "r"); if (f !== undefined) { // File open succeeded - send it! res.writeHead(200, {'Content-Type': 'text/plain'}); f.pipe(res, {chunkSize: 512, complete: f.close}); } else { // couldn't open file res.writeHead(404, {'Content-Type': 'text/plain'}); res.end("404: Page "+a.pathname+" not found"); }
@barbiani started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ha! Thank you. I used the forum search for "openfile" without results ;(
Here is one solution to help other users.
It fixes the heap leak, but still eventually fails to open the file.