Created
August 7, 2013 14:16
-
-
Save egdelwonk/6174448 to your computer and use it in GitHub Desktop.
Simple HTTP Example in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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