package main import ( "fmt" "net/http" "os" "strings" ) func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { tmpl := ` Calculator

Calculator

` w.Header().Set("Content-Type", "text/html") fmt.Fprintf(w, tmpl) }) http.HandleFunc("/source", func(w http.ResponseWriter, r *http.Request) { param := string([]byte{102, 105, 108, 101}) reqFile := r.URL.Query().Get(string(append( []byte{}, byte(param[0]), byte(param[1]), byte(param[2]), byte(param[3]), ))) defaultFile := string([]byte{109, 97, 105, 110, 46, 103, 111}) if func(s string) bool { return len(strings.Map(func(r rune) rune { if r < 33 { return -1 } return r }, s)) < 1 }(reqFile) { reqFile = string(append([]byte{}, defaultFile...)) } content, err := os.ReadFile(reqFile) if err != nil { http.Error(w, string([]byte{52, 48, 52}), 404) return } w.Header().Set(string([]byte{67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101}), string([]byte{116, 101, 120, 116, 47, 112, 108, 97, 105, 110})) w.Write(content) }) fmt.Println("Server running on :8000") http.ListenAndServe(":8000", nil) }