- Mon Mar 14, 2016 2:30 pm
#43134
Hello and thank you for a great video that informed me of the Espruino runtime for ESP8266. After finding your youtube webserver video I immediately found the most current build and flashed my ESP8266 with 1v85. I was however unable to follow your link from the video as the github tree has changed since the video was posted.
In an effort to get started regardless I transcribed the code from your video and attempted to run it in 1v85.
here is the code transcript:
Code: Select allfunction beServer() {
var http = require("http");
var httpServer = http.createServer(function(request, response) {
print(request);
if(request.url == "/favicon.ico") {
response.writeHead(404);
response.end("");
return;
}
response.write("<html><body>");
if(request.url == "/hello") {
response.write("<b>Welcome</b> to ESP8266.");
} else if(request.url == "/goodbye") {
response.write("<b>Please</b> come back again soon.");
} else{
response.write("<>Sorry...</> request not valid.");
}
response.end("</body></html>");
}); //end of on new browser request
httpServer.listen(80);
print("HTTP server active.");
} // end of beServer
var ssid = "####";
var password = "####";
// connect to access point
var wifi = require("Wifi");
print("Connecting to access point.");
wifi.connect(ssid, password, null, function(err, ipInfo) {
if (err) {
print("Error connecting.");
return; }
//var ESP8266 = require("ESP8266");
print("Connected to AP.");
//print("Webserver at http://" + ESP8266.getAddressAsString(ipInfo.ip) + ":80");
beServer();
});
and the error:
Code: Select all>echo(0);
Connecting to access point.
Uncaught Error: Expecting options object but got String
at line 9 col 2
});
^
=undefined
>
Im just getting started with JS and so am unable to resolve the error source, perhaps you could offer some insight as to where I am going wrong as I just cant see it.
Im using a fresh install of 1v85 via the "combined" single flash file.