I am accepting some data via post request on my root URL in flask and then create the PDF from that data.
I can't generate PDF until I run the parent function which then makes the data available for pdf.
How do I run the parent function via child function.
@app.route('/', methods=['POST','GET'])
def process_data():
#Some code to get the POST data
x = int(user_input)
y = 5
z = x+y
return z
@app.route('/download')
def download(args=process_data):
a = z+2
return a
You can see, I've inherited the process_data
function in download
function. If I directly go to /download
I get undefined x variable
error.
I don't want to run the whole function again and again. I just need some variables that has been processed in process_data function.
How do I fix it?
See Question&Answers more detail:os