mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
examples/_server: Enable to specify host
This commit is contained in:
parent
fabafff7ed
commit
6c10251a45
@ -32,7 +32,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var port = flag.Int("port", 8000, "port number")
|
||||
var (
|
||||
host = flag.String("host", "", "host name")
|
||||
port = flag.Int("port", 8000, "port number")
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.Parse()
|
||||
@ -165,6 +168,10 @@ func main() {
|
||||
http.HandleFunc("/main.js", serveMainJS)
|
||||
http.HandleFunc("/main.js.map", serveMainJSMap)
|
||||
http.HandleFunc("/", serveFileHandle)
|
||||
fmt.Printf("http://localhost:%d/\n", *port)
|
||||
log.Fatal(http.ListenAndServe("localhost:"+strconv.Itoa(*port), nil))
|
||||
if *host == "" {
|
||||
fmt.Printf("http://127.0.0.1:%d/\n", *port)
|
||||
} else {
|
||||
fmt.Printf("http://%s:%d/\n", *host, *port)
|
||||
}
|
||||
log.Fatal(http.ListenAndServe(*host+":"+strconv.Itoa(*port), nil))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user