Last active
August 29, 2015 14:06
-
-
Save ma6174/4977e4ca69eb5d19ab9a to your computer and use it in GitHub Desktop.
code server
This file contains 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 ( | |
"flag" | |
"log" | |
"strconv" | |
"net/http" | |
) | |
var code = flag.Int("c", 200, "code") | |
var port = flag.Int("p", 8080, "port") | |
func main() { | |
flag.Parse() | |
log.Println("server run at port", *port, "with code", *code) | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
log.Println(*code, r.URL) | |
w.WriteHeader(*code) | |
}) | |
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment