user48002: I've connected a 5-way tactile switch to a ESP8266 module and am using the Arduino IDE to create an automatically updating web server that displays the direction that the button is pressed in when pressed. Currently the webpage displays the first direction that the button was pressed in but does not update the page after I press the button several more times. Below is my code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

//ssid and password info, ommitted here for obvious reasons

int upPin = 5; 
int leftPin = 4; 
int centerPin = 0; 
int rightPin = 2; 
int downPin = 14; 

ESP8266WebServer server ( 80 );

void handleRoot() {
    server.send(200, "text/html", "<html>\
  <head>\
    <meta http-equiv='refresh' content='1'/>\
  </head>\
  <body>\
  </body>\
</html>");   // Send HTTP status 200 (Ok) and send some text to the 
browser/client
}

void setup(){
 Serial.begin ( 115200 );
 WiFi.mode ( WIFI_STA );
 WiFi.begin ( ssid, password );

 server.on ( "/", handleRoot );
 server.on ("/", button );
 server.begin();

void loop(void){
  server.handleClient(); 
  button(); 
}

void button(){
  if (digitalRead(rightPin) == LOW)
  {
    server.send(200, "text/html", "<p>*RIGHT#</p>");
    delay(10);
  }

  if (digitalRead(leftPin) == LOW)
  {
    server.send(200, "text/html", "<p>*LEFT#</p>");
    delay(10);   
  }

  if (digitalRead(upPin) == LOW)
  {
    server.send(200, "text/html", "<p>*UP#</p>");
    delay(10);
  }


  if (digitalRead(downPin) == LOW)
  {
    server.send(200, "text/html", "<p>*DOWN#</p>");
    delay(10);
  } 

  if (digitalRead(centerPin) == LOW)
  {
    server.send(200, "text/html", "<p>*CENTER#</p>");  
    delay(10);
  }

}


user48003: I changed the code so that the button function runs with "/" and took out the server.on("/", handleRoot) line, thanks to @Juraj. Sigh

48002: <p>I've connected a 5-way tactile switch to a ESP8266 module and am using the Arduino IDE to create an automatically updating web server that displays the direction that the button is pressed in when pressed. Currently the webpage displays the first direction that the button was pressed in but does not update the page after I press the button several more times. Below is my code:</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include &lt;ESP8266mDNS.h&gt;

//ssid and password info, ommitted here for obvious reasons

int upPin = 5; 
int leftPin = 4; 
int centerPin = 0; 
int rightPin = 2; 
int downPin = 14; 

ESP8266WebServer server ( 80 );

void handleRoot() {
    server.send(200, "text/html", "&lt;html&gt;\
  &lt;head&gt;\
    &lt;meta http-equiv='refresh' content='1'/&gt;\
  &lt;/head&gt;\
  &lt;body&gt;\
  &lt;/body&gt;\
&lt;/html&gt;");   // Send HTTP status 200 (Ok) and send some text to the 
browser/client
}

void setup(){
 Serial.begin ( 115200 );
 WiFi.mode ( WIFI_STA );
 WiFi.begin ( ssid, password );

 server.on ( "/", handleRoot );
 server.on ("/", button );
 server.begin();

void loop(void){
  server.handleClient(); 
  button(); 
}

void button(){
  if (digitalRead(rightPin) == LOW)
  {
    server.send(200, "text/html", "&lt;p&gt;*RIGHT#&lt;/p&gt;");
    delay(10);
  }

  if (digitalRead(leftPin) == LOW)
  {
    server.send(200, "text/html", "&lt;p&gt;*LEFT#&lt;/p&gt;");
    delay(10);   
  }

  if (digitalRead(upPin) == LOW)
  {
    server.send(200, "text/html", "&lt;p&gt;*UP#&lt;/p&gt;");
    delay(10);
  }


  if (digitalRead(downPin) == LOW)
  {
    server.send(200, "text/html", "&lt;p&gt;*DOWN#&lt;/p&gt;");
    delay(10);
  } 

  if (digitalRead(centerPin) == LOW)
  {
    server.send(200, "text/html", "&lt;p&gt;*CENTER#&lt;/p&gt;");  
    delay(10);
  }

}
</code></pre>
 48003: <p>I changed the code so that the button function runs with "/" and took out the server.on("/", handleRoot) line, thanks to @Juraj. <em>Sigh</em></p>
