title: Flask pass POST parameters to custom decorator
body: <p>I've seen the posts on passing <code>GET</code> parameters and hardcoded parameters <a href="https://stackoverflow.com/questions/18310496/flask-decorator-cant-pass-a-parameter-from-url">here</a> and <a href="https://stackoverflow.com/questions/18605764/pass-flask-route-parameters-into-a-decorator">here</a>.</p>
  
  <p>What I am trying to do is pass <code>POST</code> parameters to a custom decorator. The <code>route</code> is not actually rendering a page but rather processing some stuff and sending the results back through an AJAX call.</p>
  
  <p>The decorator looks like this:</p>
  
  <pre><code># app/util.py
  
  from functools import wraps
  from models import data
  
  # custom decorator to validate symbol
  def symbol_valid():
      def decorator(func):
          @wraps(func)
          def decorated_function(symbol, *args, **kwargs):
              if not data.validate_symbol(symbol):
                  return jsonify({'status': 'fail'})
              return func(*args, **kwargs)
          return decorated_function
      return decorator
  </code></pre>
  
  <p>The view looks something like this:</p>
  
  <pre><code># app/views/matrix_blueprint.py
  
  from flask import Blueprint, request, jsonify
  
  from ..models import data
  from ..util import symbol_valid
  
  matrix_blueprint = Blueprint('matrix_blueprint', __name__)
  
  # routing for the ajax call to return symbol details
  @matrix_blueprint.route('/route_line', methods=['POST'])
  @symbol_valid
  def route_line():
      symbol = request.form['symbol'].upper()
      result = data.get_information(symbol)
      return jsonify(**result)
  </code></pre>
  
  <p>I understand that I can actually call <code>@symbol_valid()</code> when I pass a parameter through <code>GET</code> like this <code>/quote_line/&lt;symbol&gt;</code> but I need to <code>POST</code>.</p>
  
  <p>The question then is how can my decorator access the <code>POST</code>ed variable?</p>