Can't figure out a way to display processed data output(list of dictionary) on a new web page

Issue

I have processed the query from the query.html page, but i just can’t figure out a way to display the output on a new web page. I can’t pass it as a parameter to the new url because a parameter can only be a string , int,float , or a path.

app.route("/query",methods=["GET","POST"])
def inp():
   if request.method == "POST":
        link=request.form["lnk"]
        a=int(request.form["ll"])
        b=int(request.form["ul"])
        all_posts=process(link,a,b)
       return redirect(url_for("res"))
    else:
       return render_template('query.html')

Alternatively, i thought, I could process the data on the new page but then display it but how do I pass ‘link’ , ‘a’, and ‘b’ on to the new page. Please help. Thanks

Solution

You can save the process result to a session and use it on your "res" view.

Even tough id use some javascript here with ajax call you can load up the data in query page without redirecting anywhere.

But yeah check flask session first its quiet simple .

session['key'] = 'value'

Good luck !

Answered By – dariokl

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published