diff --git a/Makefile b/Makefile index 63d2c0f..a460adc 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ clean: @echo "Cleaned" runs: $(TTY_SERVER) - ./$(TTY_SERVER) --url http://localhost:9090 --web_address :9090 --sender_address :7654 + ./$(TTY_SERVER) --url http://localhost:9090 --web_address :9090 --sender_address :7654 -frontend_path ./frontend/public runc: $(TTY_SENDER) ./$(TTY_SENDER) --logfile output.log --useTLS=false diff --git a/tty-server/server.go b/tty-server/server.go index 9db011c..ba27539 100644 --- a/tty-server/server.go +++ b/tty-server/server.go @@ -67,14 +67,17 @@ func (server *TTYProxyServer) serveContent(w http.ResponseWriter, r *http.Reques w.Header().Set("Content-Type", ctype) w.Write(file) } else { - _, err := os.Open(server.config.FrontendPath + string(os.PathSeparator) + name) + filePath := server.config.FrontendPath + string(os.PathSeparator) + name + _, err := os.Open(filePath) if err != nil { + log.Errorf("Couldn't find resource: %s at %s", name, filePath) w.WriteHeader(http.StatusNotFound) return } + log.Debugf("Serving %s from %s", name, filePath) - http.ServeFile(w, r, name) + http.ServeFile(w, r, filePath) } } diff --git a/tty-server/server_main.go b/tty-server/server_main.go index 2658213..9b16627 100644 --- a/tty-server/server_main.go +++ b/tty-server/server_main.go @@ -15,6 +15,7 @@ func main() { webAddress := flag.String("web_address", ":80", "The bind address for the web interface") senderAddress := flag.String("sender_address", ":6543", "The bind address for the tty_sender connections") url := flag.String("url", "http://localhost", "The public web URL the server will be accessible at") + frontendPath := flag.String("frontend_path", "frontend", "The path to the frontend resources") flag.Parse() log := MainLogger @@ -24,6 +25,7 @@ func main() { WebAddress: *webAddress, TTYSenderAddress: *senderAddress, ServerURL: *url, + FrontendPath: *frontendPath, } server := NewTTYProxyServer(config)