Browse Source

Add multi interfaces support.

zry 4 years ago
parent
commit
60a6513979
3 changed files with 3 additions and 3 deletions
  1. BIN
      SimpleHttpTestServer_Win32.exe
  2. BIN
      SimpleHttpTestServer_linux_linux
  3. 3 3
      main.go

BIN
SimpleHttpTestServer_Win32.exe


BIN
SimpleHttpTestServer_linux_linux


+ 3 - 3
main.go

@@ -6,13 +6,13 @@ import (
 	"net/http"
 )
 
-var BindPort uint
+var BindAddr string
 var PathToServe string
 var ShowHelp bool
 
 func main() {
 	flag.BoolVar(&ShowHelp, "h", false, "Show this help message.")
-	flag.UintVar(&BindPort, "b", 8000, "Port to bind")
+	flag.StringVar(&BindAddr, "b", ":8000", "Address to bind")
 	flag.StringVar(&PathToServe, "f", "./", "Path to serve")
 	flag.Parse()
 	if ShowHelp {
@@ -20,7 +20,7 @@ func main() {
 		return
 	}
 	http.Handle("/", http.FileServer(http.Dir(PathToServe)))
-	err := http.ListenAndServe(fmt.Sprintf(":%d", BindPort), nil)
+	err := http.ListenAndServe(BindAddr, nil)
 	if err != nil {
 		fmt.Println("Failed start server: ", err.Error())
 	}