Skip to content

Instantly share code, notes, and snippets.

@Deleplace
Created March 16, 2017 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deleplace/a453a275590565f3f46ce783d0b3f2a1 to your computer and use it in GitHub Desktop.
Save Deleplace/a453a275590565f3f46ce783d0b3f2a1 to your computer and use it in GitHub Desktop.
Draft of server with QR-code in HTTP response headers
package main
import (
"fmt"
"log"
"net/http"
"strings"
"time"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
qr := `
■ ■■■■■■■■■■■■■■ ■■ ■■ ■■■■■■■■■■■■■■
■ ■■ ■■ ■■■■ ■■ ■■ ■■
■ ■■ ■■■■■■ ■■ ■■■■■■■■■■ ■■ ■■■■■■ ■■
■ ■■ ■■■■■■ ■■ ■■ ■■ ■■ ■■ ■■■■■■ ■■
■ ■■ ■■■■■■ ■■ ■■■■■■■■ ■■ ■■■■■■ ■■
■ ■■ ■■ ■■ ■■ ■■ ■■ ■■
■ ■■■■■■■■■■■■■■ ■■ ■■ ■■ ■■■■■■■■■■■■■■
■ ■■■■ ■■■■■■ ■■ ■■ ■■■■■■■■
■ ■■ ■■ ■■ ■■■■ ■■■■ ■■■■
■ ■■■■■■■■■■ ■■ ■■ ■■■■ ■■■■■■■■
■ ■■■■■■ ■■ ■■■■■■ ■■ ■■
■ ■■■■■■ ■■ ■■■■■■■■ ■■ ■■■■
■ ■■ ■■■■ ■■■■■■■■■■
■ ■■■■■■■■■■■■■■ ■■ ■■ ■■ ■■
■ ■■ ■■ ■■■■ ■■ ■■
■ ■■ ■■■■■■ ■■ ■■ ■■ ■■■■
■ ■■ ■■■■■■ ■■ ■■ ■■ ■■ ■■■■ ■■■■■■
■ ■■ ■■■■■■ ■■ ■■ ■■ ■■■■■■
■ ■■ ■■ ■■■■■■ ■■ ■■■■
■ ■■■■■■■■■■■■■■ ■■ ■■ ■■ ■■
`
qr = `
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
■■■■■■■■ ■■ ■■■■■■ ■■ ■■■■■■■■
■■■■■■■■ ■■■■■■■■■■ ■■ ■■ ■■■■ ■■■■■■■■■■ ■■■■■■■■
■■■■■■■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■■■■■■■
■■■■■■■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■■■■■■■■
■■■■■■■■ ■■ ■■ ■■■■ ■■ ■■ ■■ ■■■■■■■■
■■■■■■■■ ■■■■■■■■■■ ■■ ■■ ■■ ■■ ■■■■■■■■■■ ■■■■■■■■
■■■■■■■■ ■■ ■■ ■■ ■■ ■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
■■■■■■■■ ■■■■ ■■■■■■■■■■ ■■■■ ■■ ■■■■■■■■
■■■■■■■■ ■■■■■■■■ ■■ ■■ ■■ ■■ ■■■■■■■■■■■■■■■■
■■■■■■■■■■■■ ■■ ■■ ■■ ■■■■ ■■■■■■■■■■
■■■■■■■■■■■■■■ ■■■■■■ ■■ ■■■■ ■■■■ ■■■■■■■■■■
■■■■■■■■■■■■ ■■ ■■ ■■■■■■■■ ■■■■ ■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■ ■■ ■■■■■■■■■■
■■■■■■■■ ■■■■■■■■ ■■ ■■■■ ■■■■ ■■■■■■■■■■
■■■■■■■■ ■■■■■■■■■■ ■■ ■■■■■■ ■■■■ ■■■■■■■■■■■■■■■■
■■■■■■■■ ■■ ■■ ■■ ■■ ■■■■■■■■■■ ■■■■■■■■■■■■■■
■■■■■■■■ ■■ ■■ ■■■■ ■■ ■■ ■■ ■■ ■■■■■■■■
■■■■■■■■ ■■ ■■ ■■■■■■ ■■■■ ■■■■ ■■■■■■■■■■■■
■■■■■■■■ ■■■■■■■■■■ ■■ ■■■■ ■■ ■■■■■■■■■■■■■■■■
■■■■■■■■ ■■ ■■■■■■■■■■■■ ■■ ■■■■ ■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
`
lines := strings.Split(qr, "\n")
for i, line := range lines {
w.Header().Set(fmt.Sprintf("qr%02d", i), line)
}
if f, ok := w.(http.Flusher); ok {
log.Println("Flushing")
f.Flush()
}
time.Sleep(2 * time.Second)
fmt.Fprintln(w, "Hello!!")
})
http.ListenAndServe(":9090", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment