2023-05-25 16:08:56 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
import "log"
|
|
|
|
import "net/http"
|
|
|
|
import "hnakra/service"
|
|
|
|
|
|
|
|
func main () {
|
|
|
|
static := http.FileServer(http.Dir("./static"))
|
|
|
|
|
|
|
|
http.HandleFunc("/gifs/", gifs)
|
|
|
|
http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
|
2023-05-27 01:57:27 -06:00
|
|
|
|
|
|
|
err := service.NewHTTP (
|
|
|
|
"Gifs", "Serves a lot of big gifs on one page.",
|
|
|
|
"@", "/gifs/").Run()
|
2023-05-25 16:08:56 -06:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Println("XXX", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func gifs (res http.ResponseWriter, req *http.Request) {
|
|
|
|
res.Header().Add("content-type", "text/html")
|
|
|
|
res.WriteHeader(http.StatusOK)
|
|
|
|
|
|
|
|
img := func (number int) {
|
|
|
|
fmt.Fprintf(res, "<img src='static/%d.gif'>", number)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Fprintln(res, "<!DOCTYPE html><html><head><title>Gifs</title></head><body>")
|
|
|
|
img(0)
|
|
|
|
img(1)
|
|
|
|
img(2)
|
|
|
|
img(3)
|
|
|
|
img(4)
|
|
|
|
img(5)
|
|
|
|
img(6)
|
|
|
|
img(7)
|
|
|
|
fmt.Fprintln(res, "</body></html>")
|
|
|
|
}
|