Skip to content

Instantly share code, notes, and snippets.

@ma6174
Last active August 29, 2015 14:06
Show Gist options
  • Save ma6174/4977e4ca69eb5d19ab9a to your computer and use it in GitHub Desktop.
Save ma6174/4977e4ca69eb5d19ab9a to your computer and use it in GitHub Desktop.
code server
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