I am trying to figure out the best way to get data into my template in a flask app. I have two routes, one to display the index page, and another that just returns json. I am trying to figure out the best way to access this information. Currently I have the following routes:
jsonObj = module.queryExternalApi()
@app.route("/")
def index(chapi=jsonObj):
data = getData()
return render_template('index.jade', chapi=chapi)
@app.route("/data/dashboard0")
def getData():
return jsonify(jsonObj)
In this case I just call the module which gets the data which is fine for running it locally, but I want to expose that data in @app.route('/data/dashboard0')
and get it from there (and any new data down the line). Is there a way to call one url from another, or am I going about this the wrong way?