qr/main.go

22 lines
393 B
Go
Raw Normal View History

2020-05-08 13:30:50 +00:00
package main
import (
"fmt"
qrcode "github.com/skip2/go-qrcode"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
website := req.URL.Query().Get("website")
if website != "" {
png, _ := qrcode.Encode(website, qrcode.Medium, 80)
w.Write(png)
return
}
w.WriteHeader(400)
})
fmt.Println(http.ListenAndServe(":8080", nil))
}