-->
Page 5 of 14

Re: ESP8266 AJAX [SOLVED]

PostPosted: Fri Apr 29, 2016 7:49 am
by insense
Hi!

@katz: Thank you for great example!

I have some questions...

How to serve .html page (~3KB) from file? I have entire page in one string, but it's very ugly to see. Is there any example how to store .html file in flash and then send it when you get request?

Also, I can't find API for ESP8266WebServer.

Thanks!

Re: ESP8266 AJAX [SOLVED]

PostPosted: Fri Apr 29, 2016 11:37 am
by martinayotte
For the API, look at the source https://github.com/esp8266/Arduino/blob ... ebServer.h

For defining a big HTML chunk into a variable, you can use this C++ syntax (everything between parenthesis can be plain un-escaped HTML) :

Code: Select allconst char html_page[] PROGMEM = R"=====(
html><head></head><body>
</body></html>
)=====";

Re: ESP8266 AJAX [SOLVED]

PostPosted: Fri Apr 29, 2016 12:42 pm
by insense
Many thanks! That's it! :)

Re: ESP8266 AJAX [SOLVED]

PostPosted: Fri Apr 29, 2016 1:00 pm
by martinayotte
Beware that it is define as PROGMEM, so you need to use it accordingly, otherwise you can simply remove that keyword, but it will take more RAM.