From 166c95b7bb96bb52a92465ac53668544fba9a8fb Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Fri, 21 Jun 2024 10:30:22 +0200 Subject: [PATCH] Fixed Code --- main.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d9ad936..0d2fea1 100644 --- a/main.go +++ b/main.go @@ -73,7 +73,7 @@ func streamResponse(w http.ResponseWriter, messages <-chan string) { } for msg := range messages { - formattedMessage := createStreamResponse(msg) + formattedMessage := createStreamResponse("fromLanguage", "toLanguage", msg) // Adjust as needed fmt.Fprintf(w, " %s\n\n", formattedMessage) flusher.Flush() } @@ -83,7 +83,7 @@ func downloadPackages(w http.ResponseWriter, fromLanguage, toLanguage string) { messages := make(chan string) defer close(messages) - go streamResponse(w, fromLanguage, toLanguage, messages) + go streamResponse(w, messages) cmd := exec.Command(linux, "translator/download.py", fromLanguage, toLanguage) output, err := cmd.StdoutPipe() @@ -193,11 +193,6 @@ func handleRequest(w http.ResponseWriter, r *http.Request) { return } - // Convert byte slices to strings - msg.Message = string(body) - msg.From = string(msg.From) - msg.To = string(msg.To) - if len(msg.From) > 2 || len(msg.To) > 2 { http.Error(w, "From and To fields should not be longer than 2 letters.", http.StatusBadRequest) return