1

I'm working with a Flask app that has to run an infinite function called session inside the route /init. Because session is infinite, when i have the code lay out like

@app.route('/init', methods=('GET', 'POST'))
def init():
    session(stock, batch_size, wait_time)
    return render_template('init.html', stock=stock, batch_size=batch_size, wait_time=wait_time)

the template will never get rendered. When I switch session and the return function, the template gets rendered but of course session never runs.

The reason session has to run infinitely is because it relies on real time info, and thus has to check for new info every wait_time. I want to be able to run session and update the HTML using the output (which will change every wait_time). I am extremely new to web dev, so any help would be greatly appreciated.

If it's any help, here's the full code on GitHub.

Thanks.

Julia Fasick
  • 121
  • 7
  • 2
    HTTP isn't really meant for that kind of use case. Instead you'll probably want to use something like websockets: [Websockets in Flask](https://stackoverflow.com/questions/23111654/websockets-in-flask) – manveti Jan 31 '20 at 01:41
  • what did you end up doin for this? – Mike Sandstrom Mar 25 '20 at 18:52

0 Answers0