I'm making a web app in the flask. I can't properly carry out my idea. In this case I want to receive some data from forms on the HTML page and send it to another script.py file. Then this script.py shall do some maths and return me and a couple of string variables. I want to receive them like a result of maths and put them separately on the HTML page ( like {{ var1 }} ).
Hhere is some code so that you roughly understand what the situation looks like now:
routes.py:
import some script as spst
...
@app.route('/calculate')
def calc_func():
data1 = request.form['form1input'] # timepicker input like 07:30
data2 = request.form['form2input'] # string 'hello'
data3 = request.form['form3input'] # int 55
fdata = data1[0:2] # 07
fdata = data1[3:5] # 30
fdata = data2 # 'hello'
fdata = data3 # 55
spst.mainclass.mainfunc(fdata1, fdata2, fdata3, fdata4)
# how to catch results from function above???
return render_template('index.html', output_text1, output_text2, output_text3)
somescript.py:
class mainclass(object):
def mainfunc(fdata1, fdata2, fdata3, fdata4):
localvar1 = int(fdata1)
localvar2 = int(fdata2)
localvar3 = str(fdata3)
localvar4 = int(fdata4)
# there is some maths and other actions
output_text1 = str(result1)
output_text2 = str(result2)
output_text3 = str(result3)
return output_text1, output_text2, output_text3