• Found the bug
    It was in the Get section of the code. I know the light was better in the POST code:)
    File Server Example
    http://www.espruino.com/http_file_server­

    switch (ext){
     case "html":
        res.writeHead(200, {'Content-Type': 'text/HTML'});
        f.pipe(res); // streams the file to the HTTP response
     break;
    
    

    Notice that in the example fileserver code and my program there is no res.end().
    Both produce an obscure error:

    Uncaught Error: Expecting a function to call, got Number

    By changing the program as follows:

    case "html":
        res.writeHead(200, {'Content-Type': 'text/HTML'});
        f.pipe(res,{chunkSize:4096,end:true,comp­lete:res.end()}); // streams the file to the HTTP response
     break;
    
    

    The error goes away. I first tried 512 instead of 4096 and only got a partial load of my HTML file. The 4096 is the length of the HTML file. Does the chunkSize parameter need to be the file length?
    So now the POST code req.on('data') works.

    var pdata="";
    function onPageRequest(req, res) { 
      var a = url.parse(req.url, true);
      req.on("data", function(d) {pdata+=d;});
    

    Pdata= {"name":"LED2","a":true,"cmd":"pobj.a=!p­obj.a;digitalWrite(LED2,pobj.a)"}{"name"­:"LED2","a":0,"cmd":"pobj.a=!pobj.a;digi­talWrite(LED2,pobj.a)"}

    So there are two questions.

    1. Is the chunkSize the file length?
    2. The res.end() worked, what about closing the file after the Pipe finishes?

About