• Raised here:

    https://github.com/espruino/Espruino/iss­ues/1116#issuecomment-291659546

    Following the snippet from here:

    http://www.espruino.com/Internet#transfe­rring-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)

    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(onPageReque­st).listen(8080);
    

    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?

About

Avatar for Wilberforce @Wilberforce started