Error "Python" not supported on Linux. so cahnged to "Python3"
This commit is contained in:
parent
f54ce86de9
commit
6e4504297d
16
main.go
16
main.go
|
@ -70,8 +70,8 @@ func downloadPackages(w http.ResponseWriter, fromLanguage, toLanguage string) {
|
|||
// Use a goroutine for streaming responses so we can proceed with the download
|
||||
go streamResponse(w, fromLanguage, toLanguage, messages)
|
||||
|
||||
// Start the Python command in the background
|
||||
cmd := exec.Command("python", "translator/download.py", fromLanguage, toLanguage)
|
||||
// Start the python3 command in the background
|
||||
cmd := exec.Command("python3", "translator/download.py", fromLanguage, toLanguage)
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
messages <- fmt.Sprintf("Error starting Download: %s", err.Error())
|
||||
|
@ -95,7 +95,7 @@ func downloadPackages(w http.ResponseWriter, fromLanguage, toLanguage string) {
|
|||
}
|
||||
}()
|
||||
|
||||
// Read the output of the Python command and send it to the channel
|
||||
// Read the output of the python3 command and send it to the channel
|
||||
scanner := bufio.NewScanner(output)
|
||||
firstOutputReceived := false
|
||||
for scanner.Scan() {
|
||||
|
@ -124,8 +124,8 @@ func executeTranslator(w http.ResponseWriter, message, fromLanguage, toLanguage
|
|||
// A goroutine will manage sending streamed responses
|
||||
go streamResponse(w, fromLanguage, toLanguage, messages)
|
||||
|
||||
// Start the Python command in the background
|
||||
cmd := exec.Command("python", "translator/translate.py", message, fromLanguage, toLanguage)
|
||||
// Start the python3 command in the background
|
||||
cmd := exec.Command("python3", "translator/translate.py", message, fromLanguage, toLanguage)
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
messages <- fmt.Sprintf("Error starting Translation: %s", err.Error())
|
||||
|
@ -138,7 +138,7 @@ func executeTranslator(w http.ResponseWriter, message, fromLanguage, toLanguage
|
|||
return
|
||||
}
|
||||
|
||||
// Read the output of the Python command and send it through the channel
|
||||
// Read the output of the python3 command and send it through the channel
|
||||
scanner := bufio.NewScanner(output)
|
||||
for scanner.Scan() {
|
||||
messages <- scanner.Text() // Sends each line of the output to the stream
|
||||
|
@ -183,7 +183,7 @@ func CheckLanguagesInstalled(fromCode, toCode string) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
func getAllPackages() error {
|
||||
cmd := exec.Command("python", "translator/note_all_packages.py")
|
||||
cmd := exec.Command("python3", "translator/note_all_packages.py")
|
||||
// Create a buffer to capture the standard output.
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
|
@ -247,7 +247,7 @@ func main() {
|
|||
http.HandleFunc("/api", handleRequest)
|
||||
|
||||
// Get the port number from the environment variable or use a default value
|
||||
port := "11435"
|
||||
port := "53184"
|
||||
if p := os.Getenv("PORT"); p != "" {
|
||||
port = p
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue