diff --git a/main.go b/main.go index 8a52606..cd7dd04 100644 --- a/main.go +++ b/main.go @@ -126,7 +126,7 @@ func executeTranslator(w http.ResponseWriter, message, fromLanguage, toLanguage scanner := bufio.NewScanner(output) for scanner.Scan() { - messages <- scanner.Text() + messages <- string(scanner.Bytes()) } err = cmd.Wait() diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..914f721 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,18 @@ +import requests +import json + +url = "https://tl.fabelous.app/api/rogQxDpALQdFDEYihACT/" +headers = { + "Authorization": "Token yQfZjxLCWYZQXTjepQAm", + "Content-Type": "application/json" +} +data = { + "message": "Hello, world!", + "from": "en", + "to": "de" +} + +response = requests.post(url, headers=headers, data=json.dumps(data)) + +print(response.status_code) +print(response.json())