Randomnerdtutorials posted a very nice tutorial on how to control Raspberry Pi GPIOs with a web server build in Python and Flask. By the end of the tutorial you will be able to toggle two LEDs. Or you can replace those LEDs with any output, like a relay or a transistor. Have a look in this link.