Initial commit
45
examples/gifs/main.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "net/http"
|
||||
import "crypto/tls"
|
||||
import "hnakra/service"
|
||||
|
||||
func main () {
|
||||
static := http.FileServer(http.Dir("./static"))
|
||||
|
||||
http.HandleFunc("/gifs/", gifs)
|
||||
http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
|
||||
|
||||
err := (&service.HTTP { Mount: service.Mount {
|
||||
Path: "/gifs/",
|
||||
Name: "Gifs",
|
||||
Description: "Serves a lot of big gifs on one page.",
|
||||
TLSConfig: &tls.Config { InsecureSkipVerify: true },
|
||||
}}).Run()
|
||||
|
||||
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>")
|
||||
}
|
||||
BIN
examples/gifs/static/0.gif
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
examples/gifs/static/1.gif
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
examples/gifs/static/2.gif
Normal file
|
After Width: | Height: | Size: 288 KiB |
BIN
examples/gifs/static/3.gif
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
examples/gifs/static/4.gif
Normal file
|
After Width: | Height: | Size: 608 KiB |
BIN
examples/gifs/static/5.gif
Normal file
|
After Width: | Height: | Size: 3.2 MiB |
BIN
examples/gifs/static/6.gif
Normal file
|
After Width: | Height: | Size: 6.3 MiB |
BIN
examples/gifs/static/7.gif
Normal file
|
After Width: | Height: | Size: 955 KiB |