mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
doc: Improve server
This commit is contained in:
parent
ef1e558ec6
commit
c1c8ba4d7e
@ -19,6 +19,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,8 +30,15 @@ func init() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rootPath = ""
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
_, path, _, _ := runtime.Caller(0)
|
||||||
|
rootPath = filepath.Join(filepath.Dir(path), "..", "public")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.Handle("/", http.FileServer(http.Dir("public")))
|
http.Handle("/", http.FileServer(http.Dir(rootPath)))
|
||||||
fmt.Printf("http://localhost:%d/\n", *port)
|
fmt.Printf("http://localhost:%d/\n", *port)
|
||||||
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
|
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user