Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 flask show while calculating

i am wondering if flask has the ability to render the template already halfway trough the calculation
following is example code

def my_form():

    return render_template("interface.html")

@app.route('/', methods=['POST'])
def my_form_post():

    result = "1"
    render_template("interface.html", result=result)
    result = "2"
    render_template("interface.html", result=result)
    result = "3"
    return render_template("interface.html", result=result)
i cannot find online how to make this happen
thanks for any help
i would like to make a bump on this subject

does somebody has an idea if it is possible?

until now i wasnt watching into other platforms than flask
maybe django or others can help me out

havent got time to take a look into django, but would like to know if it is possible before I take the effort

thanks in advance guys
Why do you want to do that? What are you actually trying to achieve? Remember that HTTP is request/response - the client always has to make a request, rather than have data pushed to it. If you want bidirectional communication, i.e. to be able to push data from the server to the client, then look into WebSockets.
I agree with @ndc85430 that need more information about the task.
Usually you don't want template to be rendered each time result will be updated.
Can update result with eg AJAX,then do not need to reloading/render template each time.
Other way Flask-SocketIO with on the client side,if need a more advance bidirectional communication.

Look at this post.
So there i am using AJAX to get value from server that eg could be your result every 10-sec.
i will take a look at the given info, thanks for your efforts guys...

i am scraping multiple webshops and give the data back to an page produced by flask

the scraping takes some time
the more webshops i scrape, the more the user has to wait

it would be nice to show the result of the first webshop already when finished scraping the first webshop,

once 2nd webshop is done, ... (adding the extra results to the page)

and 3th ....
Here is an other post you can look at.
So here is doing scheduling on the Flask server with APScheduler.
Last in post also demo with DB flask_sqlalchemy(what you always should use DB connection in Flask).

Both of solution i posted here could work for what you doing.
Just write a result check eg if webshop2 is done: then ready to send to page.
The scheduling just work at interval you set,the if a webshop is finish on next scheduling time it will send to page,if not finish send nothing.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  show csv file in flask template.html rr28rizal 5 19,098 Nov-12-2017, 01:53 PM
Last Post: rr28rizal

Forum Jump:

Users browsing this thread: 1 Guest(s)