title: Passing objects through Flask URL's
body: <p>I am working on a site using Flask that is pulling data from an API, processing it into JSON, and then dynamically loading it throughout the site as needed. I am having an issue with matching the URL appropriately while at the same time efficiently loading what data I need. </p>
  
  <p>Here is my main file:</p>
  
  <pre><code>import requests
  from flask import Flask, render_template
  
  app = Flask(__name__)
  
  url = 'https://omgvamp-hearthstone-v1.p.mashape.com/cards'
  myHeaders={
    "X-Mashape-Key": 'key-here',
    "Accept": "application/json"
  }
  r = requests.get(url, headers=myHeaders)
  cards = r.json()
  badSets = ['Promo', 'Hall of Fame', 'Tavern Brawl', 'Hero Skins', '    Missions', 'Credits', 'System', 'Debug']
  
  @app.route('/')
  def index():
      return render_template('index.html', cards=cards, badSets=badSets)
  
  
  @app.route('/&lt;setName&gt;', methods=['GET'])
  def set(setName):
      return render_template('set.html', cards=cards, setName=setName, badSets=badSets)
  
  
  @app.route('/&lt;setName&gt;/&lt;cardName&gt;', methods=['GET'])
  def individualCard(setName, cardName):
      return render_template('card.html', cards=cards, setName=setName, cardName=cardName, badSets=badSets)
  </code></pre>
  
  <p>First, I'd prefer to not have to pass each html page all of my data. Is there some way to pull only what is needed and ignore the rest?</p>
  
  <p>Second, I would like to pass a dictionary object i.e. </p>
  
  <pre><code>if card['name'] == card[setName][--index--][cardName]:
      pass card object to html page here
  </code></pre>
  
  <p>How could this be achieved, and is it possible without having to use a for-loop through all of my data?</p>
  
  <p>I'm happy to load my html pages if needed.</p>