One important thing to keep in mind is that you will have to enter your Arduino's IP address in both of the examples below in order for them to work.
The following code changes the web page served based on a button press:
To make this example code work, simply attach a button between pin D2 and 5V, a 10K resistor between pin D2 and ground, and then load the IP address of your Arduino into your web browser. The page should load with a black background. Press and hold the button, and then refresh the browser page. The site should now load with a white background.
The following code lights up an LED depending on the URL that is sent to the Arduino:
To make this work connect the positive lead an LED to pin D2, and the negative lead in series with a 220 ohm resistor to ground.
To turn on the LED enter this into your browser:
http://[YOUR IP ADDRESS HERE]/$1
To turn off the LED enter this into your browser:
http://[YOUR IP ADDRESS HERE]/$2
Note: You should obviously replace [YOUR IP ADDRESS HERE] with your IP address.