title: Call a route from within another route in Flask
body: <p>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:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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 <code>@app.route('/data/dashboard0')</code> 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?</p>