check this code,and create anew fixed.  import os
import sys
from flask import Flask, render_template, request, flash
from threading import Thread
from subprocess import Popen, PIPE

name_input = ""
app = Flask(__name__)
app.secret_key = "lsdkjhsdkmd_fnsdsderg"
print("entrando")
messages = ""
# Define the Popen instance outside of the functions
process = Popen(['/media/Elements/models/LLaMA/llama.cpp/examples/gpt4all-new.sh'], stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True,encoding='utf-8')

def run_gpt4all():
    print("rodando sh")
    #process = Popen(['/media/Elements/models/LLaMA/llama.cpp/examples/gpt4all-new.sh'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    output, _ = process.communicate()#input=name_input.encode()
    messages = output
    flash(messages)
    return messages

def update_gpt4all(process):
		global output
		print("rodando update")
		output, _ = process.communicate()
		messages = output
		print(messages)
		return messages
		
@app.route("/chat")
def index():
    print("INDEX DEF")
    thread = Thread(target=run_gpt4all)
    thread.start()
    flash(messages)
    return render_template("index.html")

@app.route("/send", methods=["POST", "GET"])
def send():
    global name_input
    print("SEND DEF")
    name_input = request.form['name_input']
    output = name_input
    process.stdin.write(output)
    thread = Thread(target=update_gpt4all, args=(process,))
    flash(messages)
    thread.start()
    return render_template("send.html") You should write your response with 200 or more words.
user