Skip to content

Instantly share code, notes, and snippets.

@egdelwonk
Created August 7, 2013 14:16
Show Gist options
  • Save egdelwonk/6174448 to your computer and use it in GitHub Desktop.
Save egdelwonk/6174448 to your computer and use it in GitHub Desktop.
Simple HTTP Example in Go
package main
import (
"net/http"
"text/template"
)
var uploadTemplate, err = template.ParseFiles("upload.html")
var doneTemplate, err2 = template.ParseFiles("done.html")
func upload(w http.ResponseWriter, r *http.Request){
if r.Method != "POST" {
uploadTemplate.Execute(w, nil)
} else {
doneTemplate.Execute(w, nil)
}
}
func main() {
http.HandleFunc("/", upload)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment