title: Pass in dict to function called via Flask
body: <p>How do I pass a dictionary in to a python 2.7 function called via a Flask POST request that are not derived from the URL (or inbound via the POST request) but generated used elsewhere in my script, e.g. </p>
  
  <pre><code>@app.route('/url_route', methods=['POST'])
  def my_function(foo, bar):
      baz = foo + bar # both are 'internal' variables, e.g. not via POST
  
      (do other stuff with inbound data from POST request)
  
      return baz, other stuff
  </code></pre>
  
  <p>When I try and trigger my_function via the POST request I get an error:</p>
  
  <pre><code>my_function() takes exactly 2 arguments (0 given)
  </code></pre>
  
  <p>I know could avoid this by declaring them both global, e.g.</p>
  
  <pre><code>def my_function(foo, bar):
      global foo
      global bar
  
      baz = foo + bar
  </code></pre>
  
  <p>Bu do I have any other alternatives?</p>