package main

import (
    "fmt"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    if (r.URL.Path[1:] == "spider") {
    fmt.Fprintf(w, "<html><head><title>%s ... You Guessed right</title></head><body style='background-color:red'><p>Hi there, I have mixed feelings about the %s!  What is your worst nightmare? %s%s%s", r.URL.Path[1:], r.URL.Path[1:], "<input onchange=' window.location = \"http://localhost:8080/\" + this.value;' type='text' value=''></input></p>&nbsp;<iframe width=600 height=400 src='http://en.wikipedia.org/wiki/", r.URL.Path[1:], "'></iframe></body></html>")
    } else {
    fmt.Fprintf(w, "<html><head><title>%s ... Guess which animal scares</title></head><body style='background-color:lightblue'><span>Hi there, I love the %s! %s%s%s", r.URL.Path[1:], r.URL.Path[1:], "</p><select onchange=' window.location = \"http://localhost:8080/\" + this.value;'><option value=''>Please select animal below</option><option value='anaconda'>anaconda</option><option value='bear'>bear</option><option value='cougar'>cougar</option><option value='deer'>deer</option><option value='elephant'>elephant</option><option value='fox'>fox</option><option value='galah'>galah</option><option value='hedgehog'>hedgehog</option><option value='ibis'>ibis</option><option value='jaguar'>jaguar</option><option value='kingfisher'>kingfisher</option><option value='llama'>llama</option><option value='monkey'>monkey</option><option value='newt'>newt</option><option value='otter'>otter</option><option value='penguin'>penguin</option><option value='quoll'>quoll</option><option value='raccoon'>raccoon</option><option value='spider'>spider</option><option value='tiger'>tiger</option><option value='uakari'>uakari</option><option value='vulture'>vulture</option><option value='whale'>whale</option><option value='xiphias'>xiphias</option><option value='yak'>yak</option><option value='zebra'>zebra</option></select></span>&nbsp;<iframe width=600 height=400 src='http://en.wikipedia.org/wiki/", r.URL.Path[1:], "'></iframe></body></html>")
    }
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

