Hello and thanks in advance for any help. I am trying to set up a ReactJS & Flask Web App, but i am having trouble getting the data into Flask, i am using Insomnia to test send the data to Flask, and the POST request returns code 200, but i keep on getting the error on the printscreen below, UnboundLocalError: local variable 'text' referenced before assignment. The string is not passed to the TTS (text-to-speech) class for processing, when i use direct assignment for the strings on the comented code bellow the imports works fine.
I have tried to send the data with JSON, now i am trying with form format, it returns the same error.
Can you help me, please, and take a look at my code ?
from flask import Flask, render_template, request
import speak
# text = "AI AI minha machadinha !!"
# lang = "pt"
app = Flask(__name__, static_folder="../static/dist", template_folder="../static")
@app.route("/", methods=["GET","POST"])
def index():
return render_template("index.html")
@app.route("/hello", methods=["GET","POST"])
def hello():
if request.method == "POST":
text = request.form["text"]
lang = request.form["lang"]
print("passou")
return speak.get_speak(text,lang)
if __name__ == "__main__":
app.run()