Browse Source

can pass host info as argument

bmallred 9 years ago
parent
commit
bd128175ec
1 changed files with 8 additions and 2 deletions
  1. 8 2
      main.go

+ 8 - 2
main.go

3
import (
3
import (
4
	"log"
4
	"log"
5
	"net/http"
5
	"net/http"
6
	"os"
6
	"path/filepath"
7
	"path/filepath"
7
)
8
)
8
9
12
		log.Fatal(err)
13
		log.Fatal(err)
13
	}
14
	}
14
15
15
	log.Println("Server running at http://localhost:8000")
16
	log.Fatal(http.ListenAndServe(":8000", http.FileServer(http.Dir(d))))
16
	addr := os.Args[1]
17
	if addr == "" {
18
		addr = ":8000"
19
	}
20
21
	log.Println("Server running at " + addr)
22
	log.Fatal(http.ListenAndServe(addr, http.FileServer(http.Dir(d))))
17
}
23
}