Skip to content

Instantly share code, notes, and snippets.

@messyidea
Last active June 2, 2016 10:39
Show Gist options
  • Save messyidea/f89a813ed771a461a7ab8ae42d0dfa6c to your computer and use it in GitHub Desktop.
Save messyidea/f89a813ed771a461a7ab8ae42d0dfa6c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"flag"
)
var (
argPort string
)
func main() {
flag.StringVar(&argPort, "port", "", "Port, default is 8080.")
flag.Parse()
if argPort == "" {
argPort = "8080"
}
fs := http.FileServer(http.Dir("."))
http.Handle("/", fs)
bind :=fmt.Sprintf("%s:%s", "0.0.0.0", argPort)
fmt.Printf("listening on %s...", bind)
http.ListenAndServe(bind, nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment