• This is better, but it's still so unreliable as to be useless. If the ESP8266 is going to be used with the Pico's that are going out, major improvements are necessary. A few calls went well... then a call that had worked before failed, and now the server is not answering http requests. Additionally I can't seem to revive the ESP without a hard power cycle. Sometimes I need to do it twice, because it doesn't respond to AT+RST,

    
    ["AT+CIPSEND=1,43\r\n\r\n\r\nInvalid json data requested: /test.json"
    ] "> " <--- "> "
    ] "> \r" <--- "\r"
    ] "\nSEND" <--- "\nSEND"
    ] "SEND OK" <--- " OK"
    ] "SEND OK\r\n" <--- "\r\n"
    ["AT+CIPCLOSE=1\r\n"
    ] "\r" <--- "\r"
    ] "\nOK" <--- "\nOK"
    ] "OK\r\n" <--- "\r\n"
    ] "Un" <--- "Un"
    ] "Unlin" <--- "lin"
    ] "Unlink\r\n" <--- "k\r\n"
    ] "Lin" <--- "Lin"
    ] "Link\r" <--- "k\r"
    ] "\nLink" <--- "\nLink"
    ] "Link\r\n" <--- "\r\n"
    ] "\r\n" <--- "\r\n"
    ] "+IPD" <--- "+IPD"
    ] "+IPD,0,3" <--- ",0,3"
    ] "+IPD,0,352:G" <--- "52:G"
    ] "+IPD,0,351:ET /st" <--- "ET /st"
    ] "+IPD,0,345:atus." <--- "atus."
    ] "+IPD,0,340:json H" <--- "json H"
    ] "+IPD,0,334:TTP/1" <--- "TTP/1"
    ] "+IPD,0,329:.1\r\nH" <--- ".1\r\nH"
    ] "+IPD,0,324:ost: 1" <--- "ost: 1"
    ] "+IPD,0,318:92.16" <--- "92.16"
    ] "+IPD,0,313:8.2.10" <--- "8.2.10"
    ] "+IPD,0,307:2\r\nCo" <--- "2\r\nCo"
    ] "+IPD,0,302:nnecti" <--- "nnecti"
    ] "+IPD,0,296:on: k" <--- "on: k"
    ] "+IPD,0,291:eep-a" <--- "eep-a"
    ] "+IPD,0,286:live\r\n" <--- "live\r\n"
    ] "+IPD,0,280:Accep" <--- "Accep"
    ] "+IPD,0,275:t: tex" <--- "t: tex"
    ] "+IPD,0,269:t/htm" <--- "t/htm"
    ] "+IPD,0,264:l,app" <--- "l,app"
    ] "+IPD,0,259:licati" <--- "licati"
    ] "+IPD,0,253:on/xh" <--- "on/xh"
    ] "+IPD,0,248:tml+xm" <--- "tml+xm"
    ] "+IPD,0,242:l,app" <--- "l,app"
    ] "+IPD,0,237:licati" <--- "licati"
    ] "+IPD,0,231:on/xm" <--- "on/xm"
    ] "+IPD,0,226:l;q=0." <--- "l;q=0."
    ] "+IPD,0,220:9,ima" <--- "9,ima"
    ] "+IPD,0,215:ge/we" <--- "ge/we"
    ] "+IPD,0,210:bp,*/*" <--- "bp,*/*"
    ] "+IPD,0,204:;q=0." <--- ";q=0."
    ] "+IPD,0,199:8\r\nUse" <--- "8\r\nUse"
    ] "+IPD,0,193:r-Age" <--- "r-Age"
    ] "+IPD,0,188:nt: Mo" <--- "nt: Mo"
    ] "+IPD,0,182:zilla" <--- "zilla"
    ] "+IPD,0,177:/5.0 " <--- "/5.0 "
    ] "+IPD,0,172:(Windo" <--- "(Windo"
    ] "+IPD,0,166:ws NT" <--- "ws NT"
    ] "+IPD,0,161: 6.3; " <--- " 6.3; "
    ] "+IPD,0,155:WOW64" <--- "WOW64"
    ] "+IPD,0,150:) Appl" <--- ") Appl"
    ] "+IPD,0,144:eWebK" <--- "eWebK"
    ] "+IPD,0,139:it/53" <--- "it/53"
    ] "+IPD,0,134:7.36 (" <--- "7.36 ("
    ] "+IPD,0,128:KHTML" <--- "KHTML"
    ] "+IPD,0,123:, like" <--- ", like"
    ] "+IPD,0,117: Geck" <--- " Geck"
    ] "+IPD,0,112:o) Chr" <--- "o) Chr"
    ] "+IPD,0,106:ome/4" <--- "ome/4"
    ] "+IPD,0,101:1.0.22" <--- "1.0.22"
    ] "+IPD,0,95:72.11" <--- "72.11"
    ] "+IPD,0,90:8 Saf" <--- "8 Saf"
    ] "+IPD,0,85:ari/53" <--- "ari/53"
    ] "+IPD,0,79:7.36\r" <--- "7.36\r"
    ] "+IPD,0,74:\nAcce" <--- "\nAcce"
    ] "+IPD,0,69:pt-Enc" <--- "pt-Enc"
    ] "+IPD,0,63:oding" <--- "oding"
    ] "+IPD,0,58:: gzip" <--- ": gzip"
    ] "+IPD,0,52:, def" <--- ", def"
    ] "+IPD,0,47:late, " <--- "late, "
    ] "+IPD,0,41:sdch\r" <--- "sdch\r"
    ] "+IPD,0,36:\nAcce" <--- "\nAcce"
    ] "+IPD,0,31:pt-Lan" <--- "pt-Lan"
    ] "+IPD,0,25:guage" <--- "guage"
    ] "+IPD,0,20:: en-U" <--- ": en-U"
    ] "+IPD,0,14:S,en;" <--- "S,en;"
    ] "+IPD,0,9:q=0.8" <--- "q=0.8"
    ] "+IPD,0,4:\r\n\r\n\r\n" <--- "\r\n\r\n\r\n"
    ] "OK\r\n\r\n" <--- "OK\r\n\r\n"
    ] "+IPD,1," <--- "+IPD,1,"
    ] "+IPD,1,352:" <--- "352:"
    ] "+IPD,1,352:GET /s" <--- "GET /s"
    ] "+IPD,1,346:tatus" <--- "tatus"
    ] "+IPD,1,341:.json" <--- ".json"
    ] "+IPD,1,336: HTTP/" <--- " HTTP/"
    ] "+IPD,1,330:1.1\r\n" <--- "1.1\r\n"
    ] "+IPD,1,325:Host: " <--- "Host: "
    ] "+IPD,1,319:192.1" <--- "192.1"
    ] "+IPD,1,314:68.2.1" <--- "68.2.1"
    ] "+IPD,1,308:02\r\nC" <--- "02\r\nC"
    ] "+IPD,1,303:onnec" <--- "onnec"
    ] "+IPD,1,298:tion: " <--- "tion: "
    ] "+IPD,1,292:keep-" <--- "keep-"
    ] "+IPD,1,287:alive\r" <--- "alive\r"
    ] "+IPD,1,281:\nAcce" <--- "\nAcce"
    ] "+IPD,1,276:pt: te" <--- "pt: te"
    ] "+IPD,1,270:xt/ht" <--- "xt/ht"
    ] "+IPD,1,265:ml,ap" <--- "ml,ap"
    ] "+IPD,1,260:plicat" <--- "plicat"
    ] "+IPD,1,254:ion/x" <--- "ion/x"
    ] "+IPD,1,249:html+x" <--- "html+x"
    ] "+IPD,1,243:ml,ap" <--- "ml,ap"
    ] "+IPD,1,238:plicat" <--- "plicat"
    ] "+IPD,1,232:ion/x" <--- "ion/x"
    ] "+IPD,1,227:ml;q=" <--- "ml;q="
    ] "+IPD,1,222:0.9,im" <--- "0.9,im"
    ] "+IPD,1,216:age/w" <--- "age/w"
    ] "+IPD,1,211:ebp,*/" <--- "ebp,*/"
    ] "+IPD,1,205:*;q=0" <--- "*;q=0"
    ] "+IPD,1,200:.8\r\nUs" <--- ".8\r\nUs"
    ] "+IPD,1,194:er-Ag" <--- "er-Ag"
    ] "+IPD,1,189:ent: M" <--- "ent: M"
    ] "+IPD,1,183:ozill" <--- "ozill"
    ] "+IPD,1,178:a/5.0" <--- "a/5.0"
    ] "+IPD,1,173: (Wind" <--- " (Wind"
    ] "+IPD,1,167:ows N" <--- "ows N"
    ] "+IPD,1,162:T 6.3;" <--- "T 6.3;"
    ] "+IPD,1,156: WOW6" <--- " WOW6"
    ] "+IPD,1,151:4) Ap" <--- "4) Ap"
    ] "+IPD,1,146:pleWeb" <--- "pleWeb"
    ] "+IPD,1,140:Kit/5" <--- "Kit/5"
    ] "+IPD,1,135:37.36 " <--- "37.36 "
    ] "+IPD,1,129:(KHTM" <--- "(KHTM"
    ] "+IPD,1,124:L, lik" <--- "L, lik"
    ] "+IPD,1,118:e Gec" <--- "e Gec"
    ] "+IPD,1,113:ko) Ch" <--- "ko) Ch"
    ] "+IPD,1,107:rome/" <--- "rome/"
    ] "+IPD,1,102:41.0." <--- "41.0."
    ] "+IPD,1,97:2272.1" <--- "2272.1"
    ] "+IPD,1,91:18 Sa" <--- "18 Sa"
    ] "+IPD,1,86:fari/5" <--- "fari/5"
    ] "+IPD,1,80:37.36" <--- "37.36"
    ] "+IPD,1,75:\r\nAcce" <--- "\r\nAcce"
    ] "+IPD,1,69:pt-En" <--- "pt-En"
    ] "+IPD,1,64:codin" <--- "codin"
    ] "+IPD,1,59:g: gzi" <--- "g: gzi"
    ] "+IPD,1,53:p, de" <--- "p, de"
    ] "+IPD,1,48:flate, sd" <--- "flate, sd"
    ] "+IPD,1,39:ch\r\nAc" <--- "ch\r\nAc"
    ] "+IPD,1,33:cept-" <--- "cept-"
    ] "+IPD,1,28:Langua" <--- "Langua"
    ] "+IPD,1,22:ge: e" <--- "ge: e"
    ] "+IPD,1,17:n-US," <--- "n-US,"
    ] "+IPD,1,12:en;q=0" <--- "en;q=0"
    ] "+IPD,1,6:.8\r\n\r" <--- ".8\r\n\r"
    ] "+IPD,1,1:\n\r\nOK" <--- "\n\r\nOK"
    ] "OK\r\n" <--- "\r\n"
    json
    ["AT+CIPSEND=0,64\r\nHTTP/1.0 200 OK\r\nServer: Espruino 1v76\r\nContent-Type: text/plain"
    ] ">" <--- ">"
    ["AT+CIPSEND=0,64\r\n\r\n\r\n{gtg:true,dtf:false,missiles:[\"armed\",\"armed\",\"repair\",\"moth"
    ] "> busy" <--- "busy"
    ] "> busy in" <--- " in"
    ] "> busy inet..." <--- "et..."
    ] "> busy inet...\r\n\r" <--- "\r\n\r"
    ] "\nERROR\r\n\r\n" <--- "\nERROR\r\n\r\n"
    ] "wrong sy" <--- "wrong sy"
    ] "wrong synta" <--- "nta"
    ] "wrong syntax\r\n\r" <--- "x\r\n\r"
    ] "\nERROR\r" <--- "\nERROR\r"
    ] "\n\r\nwr" <--- "\n\r\nwr"
    ] "wrong s" <--- "ong s"
    ] "wrong syn" <--- "yn"
    ] "wrong syntax" <--- "tax"
    ] "wrong syntax\r\n\r" <--- "\r\n\r"
    ] "\nERROR\r" <--- "\nERROR\r"
    ] "\n" <--- "\n"
    ["AT+CIPSEND=0,9\r\nballed\"]}"
    ] "b" <--- "b"
    ] "bus" <--- "us"
    ] "busy i" <--- "y i"
    ] "busy inet" <--- "net"
    ] "busy inet..." <--- "..."
    ] "busy inet...\r\n\r" <--- "\r\n\r"
    ["AT+CIPCLOSE=0\r\n"
    ] "\nERROR\r\n" <--- "\nERROR\r\n"
    json
    ] "busy i" <--- "busy i"
    ] "busy inet" <--- "net"
    ] "busy inet..." <--- "..."
    ] "busy inet...\r\n\r" <--- "\r\n\r"
    ] "\nERROR" <--- "\nERROR"
    ] "ERROR\r\n" <--- "\r\n"
    ["AT+CIPSEND=1,64\r\nHTTP/1.0 200 OK\r\nServer: Espruino 1v76\r\nContent-Type: text/plain"
    ] "bu" <--- "bu"
    ] "busy " <--- "sy "
    ] "busy ine" <--- "ine"
    ] "busy inet...\r" <--- "t...\r"
    ] "\n\r\nERR" <--- "\n\r\nERR"
    ] "ERROR\r\n\r\n" <--- "OR\r\n\r\n"
    ] "wrong sy" <--- "wrong sy"
    ] "wrong synta" <--- "nta"
    ] "wrong syntax\r\n" <--- "x\r\n"
    ] "\r\nERR" <--- "\r\nERR"
    ] "ERROR\r\n\r" <--- "OR\r\n\r"
    ] "\nwrong " <--- "\nwrong "
    ] "wrong syn" <--- "syn"
    ] "wrong syntax" <--- "tax"
    ] "wrong syntax\r\n\r" <--- "\r\n\r"
    ] "\nERROR\r" <--- "\nERROR\r"
    ] "\n" <--- "\n"
    ["AT+CIPSEND=1,64\r\n\r\n\r\n{gtg:true,dtf:false,missiles:[\"armed\",\"armed\",\"repair\",\"moth"
    ] "b" <--- "b"
    ] "busy" <--- "usy"
    ] "busy ine" <--- " ine"
    ] "busy inet..." <--- "t..."
    ] "busy inet...\r\n\r" <--- "\r\n\r"
    ] "\nERROR\r\n\r\n" <--- "\nERROR\r\n\r\n"
    ] "wrong sy" <--- "wrong sy"
    ] "wrong syntax" <--- "ntax"
    ] "wrong syntax\r\n" <--- "\r\n"
    ] "\r\nERRO" <--- "\r\nERRO"
    ] "ERROR\r\n\r\n" <--- "R\r\n\r\n"
    ] "wrong s" <--- "wrong s"
    ] "wrong synt" <--- "ynt"
    ] "wrong syntax\r" <--- "ax\r"
    ] "\n\r\nE" <--- "\n\r\nE"
    ] "ERROR\r" <--- "RROR\r"
    ] "\n" <--- "\n"
    ["AT+CIPSEND=1,9\r\nballed\"]}"
    ] "bus" <--- "bus"
    ] "busy i" <--- "y i"
    ] "busy ine" <--- "ne"
    ] "busy inet.." <--- "t.."
    ] "busy inet...\r\n" <--- ".\r\n"
    ["AT+CIPCLOSE=1\r\n"
    ] "\r\nERROR\r" <--- "\r\nERROR\r"
    ] "\n" <--- "\n"
    ] "bu" <--- "bu"
    ] "busy " <--- "sy "
    ] "busy ine" <--- "ine"
    ] "busy inet.." <--- "t.."
    ] "busy inet...\r\n" <--- ".\r\n"
    ] "\r\nER" <--- "\r\nER"
    ] "ERROR\r\n" <--- "ROR\r\n"
    ] "L" <--- "L"
    ] "Lin" <--- "in"
    ] "Link\r\n" <--- "k\r\n"
    ] "Link\r" <--- "Link\r"
    ] "\n\r\n+" <--- "\n\r\n+"
    ] "+IPD," <--- "IPD,"
    ] "+IPD,2,352" <--- "2,352"
    ] "+IPD,2,352:GET" <--- ":GET"
    ] "+IPD,2,349: /sta" <--- " /sta"
    ] "+IPD,2,344:tus.js" <--- "tus.js"
    ] "+IPD,2,338:on HT" <--- "on HT"
    ] "+IPD,2,333:TP/1.1" <--- "TP/1.1"
    ] "+IPD,2,327:\r\nHos" <--- "\r\nHos"
    ] "+IPD,2,322:t: 192" <--- "t: 192"
    ] "+IPD,2,316:.168." <--- ".168."
    ] "+IPD,2,311:2.102" <--- "2.102"
    ] "+IPD,2,306:\r\nConn" <--- "\r\nConn"
    ] "+IPD,2,300:ectio" <--- "ectio"
    ] "+IPD,2,295:n: kee" <--- "n: kee"
    ] "+IPD,2,289:p-ali" <--- "p-ali"
    ] "+IPD,2,284:ve\r\nAc" <--- "ve\r\nAc"
    ] "+IPD,2,278:cept:" <--- "cept:"
    ] "+IPD,2,273: text" <--- " text"
    ] "+IPD,2,268:/html," <--- "/html,"
    ] "+IPD,2,262:appli" <--- "appli"
    ] "+IPD,2,257:cation" <--- "cation"
    ] "+IPD,2,251:/xhtm" <--- "/xhtm"
    ] "+IPD,2,246:l+xml," <--- "l+xml,"
    ] "+IPD,2,240:appli" <--- "appli"
    ] "+IPD,2,235:catio" <--- "catio"
    ] "+IPD,2,230:n/xml;" <--- "n/xml;"
    ] "+IPD,2,224:q=0.9" <--- "q=0.9"
    ] "+IPD,2,219:,image" <--- ",image"
    ] "+IPD,2,213:/webp" <--- "/webp"
    ] "+IPD,2,208:,*/*;q" <--- ",*/*;q"
    ] "+IPD,2,202:=0.8\r" <--- "=0.8\r"
    ] "+IPD,2,197:\nUser-" <--- "\nUser-"
    ] "+IPD,2,191:Agent" <--- "Agent"
    ] "+IPD,2,186:: Moz" <--- ": Moz"
    ] "+IPD,2,181:illa/5" <--- "illa/5"
    ] "+IPD,2,175:.0 (W" <--- ".0 (W"
    ] "+IPD,2,170:indows" <--- "indows"
    ] "+IPD,2,164: NT 6" <--- " NT 6"
    ] "+IPD,2,159:.3; WO" <--- ".3; WO"
    ] "+IPD,2,153:W64) " <--- "W64) "
    ] "+IPD,2,148:Apple" <--- "Apple"
    ] "+IPD,2,143:WebKit" <--- "WebKit"
    ] "+IPD,2,137:/537." <--- "/537."
    ] "+IPD,2,132:36 (KH" <--- "36 (KH"
    ] "+IPD,2,126:TML, " <--- "TML, "
    ] "+IPD,2,121:like G" <--- "like G"
    ] "+IPD,2,115:ecko)" <--- "ecko)"
    ] "+IPD,2,110: Chrom" <--- " Chrom"
    ] "+IPD,2,104:e/41." <--- "e/41."
    ] "+IPD,2,99:0.227" <--- "0.227"
    ] "+IPD,2,94:2.118 " <--- "2.118 "
    ] "+IPD,2,88:Safar" <--- "Safar"
    ] "+IPD,2,83:i/537." <--- "i/537."
    ] "+IPD,2,77:36\r\nA" <--- "36\r\nA"
    ] "+IPD,2,72:ccept-" <--- "ccept-"
    ] "+IPD,2,66:Encod" <--- "Encod"
    ] "+IPD,2,61:ing: " <--- "ing: "
    ] "+IPD,2,56:gzip, " <--- "gzip, "
    ] "+IPD,2,50:defla" <--- "defla"
    ] "+IPD,2,45:te, sd" <--- "te, sd"
    ] "+IPD,2,39:ch\r\nA" <--- "ch\r\nA"
    ] "+IPD,2,34:ccept" <--- "ccept"
    ] "+IPD,2,29:-Langu" <--- "-Langu"
    ] "+IPD,2,23:age: " <--- "age: "
    ] "+IPD,2,18:en-US," <--- "en-US,"
    ] "+IPD,2,12:en;q=" <--- "en;q="
    ] "+IPD,2,7:0.8\r\n" <--- "0.8\r\n"
    ] "+IPD,2,2:\r\n\r\nOK" <--- "\r\n\r\nOK"
    ] "OK\r\n" <--- "\r\n"
    json
    ["AT+CIPSEND=2,64\r\nHTTP/1.0 200 OK\r\nServer: Espruino 1v76\r\nContent-Type: text/plain"
    ] "b" <--- "b"
    ] "busy " <--- "usy "
    ] "busy ine" <--- "ine"
    ] "busy inet..." <--- "t..."
    ] "busy inet...\r\n\r\n" <--- "\r\n\r\n"
    ] "ERROR\r\n\r\nw" <--- "ERROR\r\n\r\nw"
    ] "wrong syn" <--- "rong syn"
    ] "wrong syntax" <--- "tax"
    ] "wrong syntax\r\n\r\n" <--- "\r\n\r\n"
    ] "ERROR\r\n" <--- "ERROR\r\n"
    ] "\r\nwro" <--- "\r\nwro"
    ] "wrong s" <--- "ng s"
    ] "wrong synt" <--- "ynt"
    ] "wrong syntax\r" <--- "ax\r"
    ] "\n\r\nER" <--- "\n\r\nER"
    ] "ERROR\r" <--- "ROR\r"
    ] "\n" <--- "\n"
    ["AT+CIPSEND=2,64\r\n\r\n\r\n{gtg:true,dtf:false,missiles:[\"armed\",\"armed\",\"repair\",\"moth"
    ] "b" <--- "b"
    ] "busy" <--- "usy"
    ] "busy ine" <--- " ine"
    ] "busy inet..." <--- "t..."
    ] "busy inet...\r\n\r" <--- "\r\n\r"
    ] "\nERROR\r\n\r\n" <--- "\nERROR\r\n\r\n"
    ] "wrong sy" <--- "wrong sy"
    ] "wrong synta" <--- "nta"
    ] "wrong syntax\r\n\r" <--- "x\r\n\r"
    ] "\nERROR\r" <--- "\nERROR\r"
    ] "\n\r\nwr" <--- "\n\r\nwr"
    ] "wrong s" <--- "ong s"
    ] "wrong synt" <--- "ynt"
    ] "wrong syntax\r" <--- "ax\r"
    ] "\n\r\nE" <--- "\n\r\nE"
    ] "ERROR\r" <--- "RROR\r"
    ] "\n" <--- "\n"
    ["AT+CIPSEND=2,9\r\nballed\"]}"
    ] "bus" <--- "bus"
    ] "busy " <--- "y "
    ] "busy ine" <--- "ine"
    ] "busy inet.." <--- "t.."
    ] "busy inet...\r\n" <--- ".\r\n"
    ["AT+CIPCLOSE=2\r\n"
    ] "\r\nERROR\r" <--- "\r\nERROR\r"
    ] "\n" <--- "\n"
    ] "bu" <--- "bu"
    ] "busy " <--- "sy "
    ] "busy ine" <--- "ine"
    ] "busy inet.." <--- "t.."
    ] "busy inet...\r\n" <--- ".\r\n"
    ] "\r\nER" <--- "\r\nER"
    ] "ERROR\r\n" <--- "ROR\r\n"
     
    

    code now is:

    
    Serial4.setup(9600, { rx: C11, tx : C10 });
    
    
    var http = require("http");
    var wifi = require("ESP8266WiFi").connect(Serial4, function(err) {
      
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect(wifi.config.ssid,wifi.config.pass, function(err) {
          if (err) throw err;
          console.log("Connected");
          wifi.getIP(function(err,ip){wifi.config.ip=ip;});
          setTimeout(wifi.userinit.bind(wifi),15000);
        });
      });
    });
    wifi.config={ssid:"TwilightZone", pass:"snip", port:80};
    wifi.fpfx="html"; //file prefix for serving files off SD card;
    
    wifi.userinit= function() { //set up the server. 
    	console.log("setting up server on "+this.config.ip+":"+this.config.port);
    	this.server=require('http').createServer(this.onRequest.bind(this)).listen(this.config.port);
    };
    wifi.onRequest=function (req, res) {
    	var par=url.parse(req.url,true);
    	var q=par.query; 
    	var nam=par.pathname; 
    	var l=nam.indexOf("/");
    	nam=nam.slice(l);
    	var rd=this.procreq(nam,q);
    	res.writeHead(rd.code,rd.head?rd.head:{'Content-Type': 'text/plain'});
    	if (!rd.file) {
    		res.write(rd.body);
            res.end();
    	} else {
    		rd.file.pipe(res);
            res.end();
    	}
    };
    
    wifi.procreq = function (path,query) {
    	var paths=path.split(".");
    	var rd={};
    	rd.code=404;
    	rd.body="";
    	// code goes here
        console.log(paths[1]);
    	if (paths[1] in this.handler) {
    		if (paths[0].slice(1) in this.handler[paths[1]]) {
    			rd=this.handler[paths[1]][paths[0].slice(1)](path,query);
    		} else if ("_" in this.handler[paths[1]]){
    			rd=this.handler[paths[1]]["_"](path,query);
    		} else { rd.body="Handler does not support this file.";}
    	}
    	else {
    		var f = E.openFile(wifi.fpfx+"/"+path, "r");
    		if (f==undefined) {
    			rd.body="File "+path+" not found";
    		} else {
    			rd.code=200;
    			rd.file=f;
    		}	
    	}
    	return rd;
    };
    wifi.handler={};
    wifi.handler.json={};
    wifi.handler.json.status= function (path,query) {
    	 return {code:200,body:'{gtg:true,dtf:false,missiles:["armed","armed","repair","mothballed"]}'};
    };
    wifi.handler.json._ = function (path,query) {
    	 return {code:404,body:"Invalid json data requested: "+path};
    };
    wifi.handler.run={};
    wifi.handler.run.code= function (path,query) {
    	 try {
    	 	return {code:200,body:+eval(query.code)}; //danger! This is about as insecure as it gets!
    	 } catch(err) {
    	 	return {code:500,body:"Error thrown: "+err};
    	 }
    };
    
    
About

Avatar for DrAzzy @DrAzzy started