frontend: Add -simulator option to serve file without nginx (usefull for some development purposes)
This commit is contained in:
parent
9ab5738cff
commit
baf12f87a3
2 changed files with 56 additions and 0 deletions
25
frontend/static.go
Normal file
25
frontend/static.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
var staticDir = "static"
|
||||
|
||||
func serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, path.Join(staticDir, "index.html"))
|
||||
}
|
||||
|
||||
type TeamMyServer struct {
|
||||
path2Dir string
|
||||
}
|
||||
|
||||
func (s TeamMyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if _, err := os.Stat(startedFile); os.IsNotExist(err) {
|
||||
http.ServeFile(w, r, path.Join(s.path2Dir, "wait.json"))
|
||||
} else {
|
||||
http.ServeFile(w, r, path.Join(s.path2Dir, "my.json"))
|
||||
}
|
||||
}
|
||||
Reference in a new issue