mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
WifiWebServer example: Moved the autorefresh feature inside the http header
This commit is contained in:
@ -78,12 +78,11 @@ void loop() {
|
|||||||
// send a standard http response header
|
// send a standard http response header
|
||||||
client.println("HTTP/1.1 200 OK");
|
client.println("HTTP/1.1 200 OK");
|
||||||
client.println("Content-Type: text/html");
|
client.println("Content-Type: text/html");
|
||||||
client.println("Connection: close");
|
client.println("Connection: close"); // the connection will be closed after completion of the response
|
||||||
|
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
|
||||||
client.println();
|
client.println();
|
||||||
client.println("<!DOCTYPE HTML>");
|
client.println("<!DOCTYPE HTML>");
|
||||||
client.println("<html>");
|
client.println("<html>");
|
||||||
// add a meta refresh tag, so the browser pulls again every 5 seconds:
|
|
||||||
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
|
|
||||||
// output the value of each analog input pin
|
// output the value of each analog input pin
|
||||||
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
|
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
|
||||||
int sensorReading = analogRead(analogChannel);
|
int sensorReading = analogRead(analogChannel);
|
||||||
@ -108,6 +107,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
// give the web browser time to receive the data
|
// give the web browser time to receive the data
|
||||||
delay(1);
|
delay(1);
|
||||||
|
|
||||||
// close the connection:
|
// close the connection:
|
||||||
client.stop();
|
client.stop();
|
||||||
Serial.println("client disonnected");
|
Serial.println("client disonnected");
|
||||||
|
Reference in New Issue
Block a user