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