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