Testing on linux ( which has a side issue of the path not working due to it not being at the root of an SD card)
echo index file > /tmp/www/index.htm
upload:
function onPageRequest(req, res) {
var a = url.parse(req.url, true);
var f = E.openFile(a.pathname, "r");
if (f !== undefined) {
res.writeHead(200, {'Content-Type': 'text/plain'});
f.pipe(res); // streams the file to the HTTP response
debugger;
} else {
res.writeHead(404, {'Content-Type': 'text/plain'});
res.end("404: Page "+a.pathname+" not found");
}
}
require("http").createServer(onPageRequest).listen(8080);
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.
Raised here:
https://github.com/espruino/Espruino/issues/1116#issuecomment-291659546
Following the snippet from here:
http://www.espruino.com/Internet#transferring-files
Testing on linux ( which has a side issue of the path not working due to it not being at the root of an SD card)
upload:
And in browser:
http://192.168.69.16:8080/tmp/www/index.htm
at the debug point in the browser, when you hit c to continue we get:
Uncaught Error: Expecting a function to call, got Number
This does not occur for the not found case..
Not sure what is causing this error or if the example needs to be updated?