title: Flask: Accessing or Passing a dictionary from one route/function to another
body: <p>Main page is a form and then when the user clicks "Calculate" there's calculations made from the form, stored in a dictionary which is then passed back to fill a table. briefly like this:</p>
  
  <pre><code>@app.route('/join', methods=['GET','POST'])
  def my_form_post():
  ---calculations done and variables set---
  
  data_dict = {
          "loco_length":l1, "loco_weight":w1, "loco_bweight":b1,
          "cargo_length":l2, "cargo_weight":w2, "cargo_bweight":b2,
          "total_length":length, "total_weight": weigth, "total_bweight": bweigth,
          "bproc":bproc
      }
  
      result = {str(key): value for key, value in data_dict.items()}
      return jsonify(result=result)</code></pre>
  
  <p>But then I've made a 2nd function which I'd like to be accessed with a new route /pdf.
  That function is to fill a pre-defined PDF-template with the values from the 'my_form_post' -dictionary. </p>
  
  <p>The 2nd route looks like this, calling a function and needs the dictionary as argument:</p>
  
  <pre><code>def pdf():
  
      data = write_fillable_pdf(PDF_TEMP_PATH, data_dict)
      return send_file(data, mimetype='application/pdf')</code></pre>
  
  <p>How do I get the dictionary to transfer or be accessible between functions and routes? I've seen people mention sessions, json and globals. But I cant figure it out.</p>
  
  <p>Thank you for any assistance.</p>