title: How to pass variable onto another route in FLASK
body: <p>I am trying to pass a variable from one route to another, but I am unable to. Can someone guide me on doing it? I get the error on the last line.</p>
  
  <pre><code>@app.route("/search", methods=['GET', 'POST'])
  def search():
  
      if request.method == 'GET':
  
          return render_template('search.html', navbar=True)
  
      else:
  
          query = request.form.get('query').lower()
          query_like = '%' + query + '%'
  
          books = db.execute('SELECT * FROM books WHERE (LOWER(isbn) LIKE :query) OR (LOWER(title) LIKE :query) '
                             'OR (LOWER(author) LIKE :query)',
                             {'query': query_like}).fetchall()
  
          if not books:
              return render_template('error.html', message='No Books were Found!', navbar=True)
  
          return render_template('books.html', query=query, books=books, navbar=True)
  
  @app.route("/books", methods=['GET', 'POST'])
  def books():
  
      return render_template('books.html', query=query, books=books)
  </code></pre>