I am building an APIs with Flask and I need to check for skipped and send them mail for skipping automatically, but with my approach Server won't start, I need to check for skipped with APIs running, without while I can access all the routes but with while the server is not even starting. is there any way to do that? thanks in advance
def check_skipped():
users = User.query.all()
for user in users:
if user.skipped == 3:
msg = Message("Skipped 3 times", sender="admin@Kill3r.tech", recipients=user.email)
msg.body = 'Open app and verify now'
mail.send(msg)
schedule.every(10).seconds.do(check_skipped)
while 1:
schedule.run_pending()
time.sleep(1)
@app.route('/user', methods=['GET'])
@token_required
def get_all_users(current_user):