Skip to content Skip to sidebar Skip to footer

How Do I Run The Parent Function In Flask?

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

Solution 1:

There is no need that every function is a view function!

If I understood your use case correctly, the user sends data, and you return a pdf.

You can do it like this (pseudo code):

defprocess_data(data):
    x = int(data)
    y = 5
    z = x+y
    return z


defgenerate_pdf(data):
    #Some code to generate a pdfreturn pdf(data)


@app.route('/download', methods=['POST','GET'])defdownload_pdf():
    #Some code to get the POST data
    processed_data = process_data(data)
    pdf = generate_pdf(pdf)
    return pdf

Post a Comment for "How Do I Run The Parent Function In Flask?"