What I want to do is a program that uses a form to receive data to perform some functions in python code, until here everything is fine, my problem is that if I want to print the result on my web page, I have to have saved the values in cache, because if I do not boot the error 'local variable' result 'referenced before assignment' what I want to do is send this information from the form, to another route, so that it already has the information saved and it can fully load , but I do not know how to send the information or how to consume it in the "app.py"
================ FILE app.py ================================= / p>
@app.route('/biseccion', methods = ['GET', 'POST'])
def biseccion():
fbiseccion = forms.FormularioBiseccion(request.form)
print 'pryeba'
print fbiseccion.data
if request.method == 'POST':
print fbiseccion.xi.data
print fbiseccion.xs.data
print fbiseccion.error.data
print fbiseccion.iteraciones.data
xistring = fbiseccion.xi.data
xstring = fbiseccion.xs.data
errorstring = fbiseccion.error.data
iteracionesstring = fbiseccion.iteraciones.data
xi = float(xistring)
xs = float(xstring)
error = float(errorstring)
iteraciones =float(iteracionesstring)
from metodo import f
from metodo import biseccion
resultado =biseccion(xi,xs,error,iteraciones)
# print(biseccion(xi,xs,error,iteraciones))
return render_template('biseccion.html', form = fbiseccion, resultado=resultado)
=============== FORMS.py ===============
from wtforms import Form
from wtforms import StringField
class FormularioBiseccion(Form):
xi=StringField('Introduce el valor de xi: ')
xs=StringField('Introduce el valor de xs: ')
error=StringField('Introduce la tolerancia: ')
iteraciones =StringField('Dame el numero de iteraciones: ')