Here I will be showing you how to turn on and off a lamp from anywhere in the world. However, you can control any device that works by toggling its power source, such as a fountain, TV, Christmas tree lights, projector, etc.
Full article here:
Make an Internet Controlled Lamp with a Raspberry Pi and Flask (jack.minardi.org)