ESP8266 Webserver ESP8266WebServer variable html page (not as one const char) The aim is to display a non-static html page depending on some variable condition.

The code I created hast the problem, that the esp8266 is ressetting in the moment I request the page.

const char htmlIndexHeader[] PROGMEM = R"=====(
&lt;html&gt;
&lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;p&gt;Hello World&lt;/p&gt;
  &lt;ol&gt;
)=====";

const char htmlIndexProgress1[] PROGMEM = R"=====(
        &lt;li&gt;lorem&lt;/li&gt;
)====="; 

const char htmlIndexProgress2[] PROGMEM = R"=====(
        &lt;li&gt;ipsum&lt;/li&gt;
)====="; 

const char htmlIndexFooter[] PROGMEM = R"=====(
        &lt;/ol&gt;
&lt;/body&gt;
&lt;/html&gt;
)====="; 

char htmlIndexAll[2000]; 

void handleRoot() 
{
  Serial.println("GET /");

   strcpy(htmlIndexAll, htmlIndexHeader);

   if(var1==true)
   {
     strcat(htmlIndexAll, htmlIndexProgress1);
   }

   if(var2==true)
   {
     strcat(htmlIndexAll, htmlIndexProgress2);
   } 

   strcat(htmlIndexAll, htmlIndexFooter);

  server.send(200, "text/html", htmlIndexAll);
}


If I display a static page the esp8266 does not restart at page request.
Compiler can't differentiate the PROGMEM strings from constant strings in SRAM strings. Both are const char*. But the PROGMEM string must be handled differently. For that reason _P variants of functions exists.

You should use stcpy_P and strcat_P functions.

Note: On esp8266 some functions of Arduino core use a trick to identify PROGMEM strings by their specific address range.