It don't have to be called in route,it work independent of that.
It's was just a demo to also send values from schedule function to client with jinja.
It's was just a demo to also send values from schedule function to client with jinja.
from flask import Flask, render_template, jsonify from apscheduler.schedulers.background import BackgroundScheduler import random import requests app = Flask(__name__) def parse_func(): response = requests.get('https://nghttp2.org/httpbin/get') r = response.json() lst = [r['url'], r['origin']] rand_value = random.choice(lst) print(rand_value) #return(rand_value) @app.route("/") def template(): return render_template('sh2.html') if __name__ == '__main__': scheduler = BackgroundScheduler() scheduler.add_job(parse_func, 'interval', seconds=15) scheduler.start() app.run(debug=True)See that it run schedule interval,and routes can to there thing not knowing about this at all.