user47000: I am trying to put a web server on my Wemos D1 mini pro. I am using this example for the Arduino code: 
https://github.com/wemos/Arduino_D1/blob/master/doc/esp8266wifi/server-examples.rst

#include <ESP8266WiFi.h>

const char* ssid = "GL-AR300M-ceb";
const char* password = "********";

WiFiServer server(80);

void setup()
{
  Serial.begin(115200);
  Serial.println();

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");

  server.begin();
  Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
}


// prepare a web page to be send to a client (web browser)
String prepareHtmlPage()
{
  String htmlPage =
     String("HTTP/1.1 200 OK\r\n") +
            "Content-Type: text/html\r\n" +
            "Connection: close\r\n" +  // the connection will be closed after completion of the response
            "Refresh: 5\r\n" +  // refresh the page automatically every 5 sec
            "\r\n" +
            "<!DOCTYPE HTML>" +
            "<html>" +
            "Analog input:  " + String(analogRead(A0)) +
            "</html>" +
            "\r\n";
  return htmlPage;
}


void loop()
{
  WiFiClient client = server.available();
  // wait for a client (web browser) to connect
  if (client)
  {
    Serial.println("\n[Client connected]");
    while (client.connected())
    {
      // read line by line what the client (web browser) is requesting
      if (client.available())
      {
        String line = client.readStringUntil('\r');
        Serial.print(line);
        // wait for end of client's request, that is marked with an empty line
        if (line.length() == 1 && line[0] == '\n')
        {
          client.println(prepareHtmlPage());
          break;
        }
      }
    }
    delay(1); // give the web browser time to receive the data

    // close the connection:
    client.stop();
    Serial.println("[Client disonnected]");
  }
}

It uploads fine and when I open the serial monitor get this:  
Connecting to GL-AR300M-ceb . connected
Web server started, open 192.168.8.119 in a web browser  
When I go to the IP address that it gives in the monitor, I only see a blank page. I also can't inspect element, so it doesn't load the HTML part I guess.
When I change the code like this:  
if (client.available())  
{  
//        String line = client.readStringUntil('\r');  
//        Serial.print(line);  
//        // wait for end of client's request, that is marked with an empty line  
//        if (line.length() == 1 && line[0] == '\n')  
//        {  
//          client.println(prepareHtmlPage());  
//          break;  
//        }  
          client.println(prepareHtmlPage());  
      }  

then i see this

And when i add the break in the code like so:  
client.println(prepareHtmlPage());  
break;  

in the code, i get the blank page again.  
Does someone have an idea what the problem might be? 

user40792: you should go for the "Advanced Webserver" example provided by the ESP8266 libraries in your Arduino IDE.
The webserver is using callbacks like
server.on ( "/", handleRoot );
server.on ( "/test.svg", drawGraph );

and so on. 
Then you can use these handles to give back a html page to your browser like
server.send(200, "text/plain", message);       //Response to the HTTP request

Note how the function returns an 200 http code to your browser, which is mandatory for showing up your web page!

47000: <p>I am trying to put a web server on my Wemos D1 mini pro. I am using this example for the Arduino code: 
<a href="https://github.com/wemos/Arduino_D1/blob/master/doc/esp8266wifi/server-examples.rst" rel="nofollow noreferrer">https://github.com/wemos/Arduino_D1/blob/master/doc/esp8266wifi/server-examples.rst</a><br>
</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;ESP8266WiFi.h&gt;

const char* ssid = "GL-AR300M-ceb";
const char* password = "********";

WiFiServer server(80);

void setup()
{
  Serial.begin(115200);
  Serial.println();

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");

  server.begin();
  Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
}


// prepare a web page to be send to a client (web browser)
String prepareHtmlPage()
{
  String htmlPage =
     String("HTTP/1.1 200 OK\r\n") +
            "Content-Type: text/html\r\n" +
            "Connection: close\r\n" +  // the connection will be closed after completion of the response
            "Refresh: 5\r\n" +  // refresh the page automatically every 5 sec
            "\r\n" +
            "&lt;!DOCTYPE HTML&gt;" +
            "&lt;html&gt;" +
            "Analog input:  " + String(analogRead(A0)) +
            "&lt;/html&gt;" +
            "\r\n";
  return htmlPage;
}


void loop()
{
  WiFiClient client = server.available();
  // wait for a client (web browser) to connect
  if (client)
  {
    Serial.println("\n[Client connected]");
    while (client.connected())
    {
      // read line by line what the client (web browser) is requesting
      if (client.available())
      {
        String line = client.readStringUntil('\r');
        Serial.print(line);
        // wait for end of client's request, that is marked with an empty line
        if (line.length() == 1 &amp;&amp; line[0] == '\n')
        {
          client.println(prepareHtmlPage());
          break;
        }
      }
    }
    delay(1); // give the web browser time to receive the data

    // close the connection:
    client.stop();
    Serial.println("[Client disonnected]");
  }
}
</code></pre>

<p>It uploads fine and when I open the serial monitor get this:  </p>

<p>Connecting to GL-AR300M-ceb . connected
Web server started, open 192.168.8.119 in a web browser  </p>

<p>When I go to the IP address that it gives in the monitor, I only see a blank page. I also can't inspect element, so it doesn't load the HTML part I guess.<br>
When I change the code like this:  </p>

<pre class="lang-cpp prettyprint-override"><code>if (client.available())  
{  
//        String line = client.readStringUntil('\r');  
//        Serial.print(line);  
//        // wait for end of client's request, that is marked with an empty line  
//        if (line.length() == 1 &amp;&amp; line[0] == '\n')  
//        {  
//          client.println(prepareHtmlPage());  
//          break;  
//        }  
          client.println(prepareHtmlPage());  
      }  
</code></pre>

<p>then i see this<br>
 <a href="https://i.stack.imgur.com/gLZHI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gLZHI.png" alt="screenshot of code as plain text in browser"></a></p>

<p>And when i add the break in the code like so:  </p>

<pre class="lang-cpp prettyprint-override"><code>client.println(prepareHtmlPage());  
break;  
</code></pre>

<p>in the code, i get the blank page again.  </p>

<p>Does someone have an idea what the problem might be? </p>
 40792: <p>you should go for the "Advanced Webserver" example provided by the ESP8266 libraries in your Arduino IDE.
The webserver is using callbacks like</p>

<pre><code>server.on ( "/", handleRoot );
server.on ( "/test.svg", drawGraph );
</code></pre>

<p>and so on. 
Then you can use these handles to give back a html page to your browser like</p>

<pre><code>server.send(200, "text/plain", message);       //Response to the HTTP request
</code></pre>

<p><strong>Note how the function returns an 200 http code to your browser, which is mandatory for showing up your web page!</strong></p>
