Chat freely about anything...

User avatar
By mjtapp62
#39033 Hi,
I have created a project using arduino 1.6.5 - simple enough just a webserver serving a couple of web pages.

I have created a couple of handlers:
//SERVER INIT
WebServer.on("/", HTTP_GET, handle_root);
WebServer.on("/index", HTTP_GET, handle_root);
WebServer.on("/mode", HTTP_POST, handle_mode);
WebServer.on("/mode", HTTP_GET, handle_mode);
WebServer.on("/tri.png", HTTP_GET, handle_tri);
WebServer.on("/favicon.ico", []() {
WebServer.send(404, "text/plain", "");});

and have the appropriate functions to deal with them.

The problem I am seeing is that when I put a URL into my browser, 10.0.0.1/ works - gets processed by handle_root perfectly.
This also works 10.0.0.1/index and 1.0.0.1/mode also OK
However if I use 10.0.0.1/index.html it jumps to filenotfound.

Is there something I am missing.

My web pages have links like <a href="mode.html"><button type="button" style.....

These cause filenot found behaviour.

Any help appreciated.
User avatar
By eduperez
#39079 I am not sure that I understood the problem here.

If you do not have handlers for "index.html", I would expect any request for "index.html" to produce a 404 error; and having a handler for "index" is clearly not enough, because the library does not assume that one is the same as the other.

If your pages contain links to "index.html", either you change them to "index" or add a handler for "index.html".
User avatar
By martinayotte
#39083 Yes, the path provide to WebServer.on() should be a perfect match of the requested path without the parameters.
So "index" is useless if you though about "index.html", you need to add the ".html".
And I think, but did not verify, those paths are probably case-sensitive.