V
V
Vladislav2020-05-08 12:32:58
Flask
Vladislav, 2020-05-08 12:32:58

How to render template in Flask interval using apscheduler?

@app.route('/')
def main():
    data = get_content()
    return render_template('article.html', data=data)

get_content() should, conditionally, look at the data every 2 minutes. After that, you need to render the template.
scheduler.add_job(main, trigger='interval', seconds=120)

Gives an error message
AttributeError: 'NoneType' object has no attribute 'app'

Perhaps it makes sense to write a second function that will call get_content, and put main itself in the add_listener of the same apscheduler. But, in theory, AttributeError will not go anywhere.
A completely different option is to add a client to Vue, but I don’t want to install vue-cli at all. The application itself is very small. Although this seems to be the only correct option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-05-08
@nitron_5

As a result, I still wrote a client in Vue and organized an interval request to the server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question