mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/_server: Enable to specify host
This commit is contained in:
parent
fabafff7ed
commit
6c10251a45
@ -32,7 +32,10 @@ import (
|
|||||||
"time"
|
"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() {
|
func init() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -165,6 +168,10 @@ func main() {
|
|||||||
http.HandleFunc("/main.js", serveMainJS)
|
http.HandleFunc("/main.js", serveMainJS)
|
||||||
http.HandleFunc("/main.js.map", serveMainJSMap)
|
http.HandleFunc("/main.js.map", serveMainJSMap)
|
||||||
http.HandleFunc("/", serveFileHandle)
|
http.HandleFunc("/", serveFileHandle)
|
||||||
fmt.Printf("http://localhost:%d/\n", *port)
|
if *host == "" {
|
||||||
log.Fatal(http.ListenAndServe("localhost:"+strconv.Itoa(*port), nil))
|
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