webserver not showing up correctly
Posted: Mon Dec 26, 2016 6:11 pm
I´ve made this webserver, but when sending it, it doesnt appear from the pressure variable to the end of the webserver, what is wrong?
Sry for my bad english
Sry for my bad english
Code: Select all
void responder_peticion() {
WiFiClient client = server.available();
if (client)
{
peticion = true;
//Serial.println("\n[Client connected]");
while (client.connected())
{
if (client.available())
{
String line = client.readStringUntil('\r');
//Serial.print(line);
if (line.length() == 1 && line[0] == '\n')
{
client.println(prepareHtmlPage0());
cantidad_envios++;
break;
}
}
}
client.stop();
//Serial.printf("[Client disonnected]\n");
}
}
String prepareHtmlPage0()
{
String htmlPage =
String("HTTP/1.1 200 OK\r\n") +
"Content-Type: text/html\r\n" +
"Connection: close\r\n" +
"Refresh: 1\r\n" +
"\r\n" +
"<!DOCTYPE html>\r\n" +
"<meta charset=\"utf-8\">" +
"<html>" +
"<head>" +
"<h1 style = \"text-align: center;\">" +
"webpage" +
"</h1>" +
"<title>" +
"site" +
"</title>" +
"<pre>" +
"</pre>" +
"</head>" +
"<body>" +
" <div id=\"page\" style=\"width: 980px; text-align: center; margin: auto; \">" +
"<pre>" +
"</pre>" +
"<p style=\"text-align: center;\">temp= " + temp + " ºC</p>" +
"<p style=\"text-align: center;\">hr= " + hum + " %</p>" +
"<p style=\"text-align: center;\">Presure= " + pres + /* FROM HERE IT DOESNT APPEAR" mB</p>" +
"<h5 style=\"text-align: center;\">Numero de envios = " + cantidad_envios + "</h5>" +
"</div>" +
"</body>" +
"</html>" +
"\r\n";
return htmlPage;
}