Skip to content

Instantly share code, notes, and snippets.

@IndianGuru
Created October 2, 2015 04:31
Show Gist options
  • Select an option

  • Save IndianGuru/29a47b60c3becdd9f4a8 to your computer and use it in GitHub Desktop.

Select an option

Save IndianGuru/29a47b60c3becdd9f4a8 to your computer and use it in GitHub Desktop.
blobstrex1.go
func init() {
http.HandleFunc("/", handleRoot)
}
func serveError(c appengine.Context, w http.ResponseWriter, err error) {
w.WriteHeader(http.StatusInternalServerError)
w.Header().Set("Content-Type", "text/plain")
io.WriteString(w, "Internal Server Error")
c.Errorf("%v", err)
}
func handleRoot(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
uploadURL, err := blobstore.UploadURL(c, "/upload", nil)
if err != nil {
serveError(c, w, err)
return
}
w.Header().Set("Content-Type", "text/html")
err = rootTemplate.Execute(w, uploadURL)
if err != nil {
c.Errorf("%v", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment