title: Python/Flask accessing variables between two methods
body: <p>I have a flask web application which has two methods. I need to access the summary variable which is in method 1 inside method 2. the following is what I have done. But it doesn't seem to work out for me.</p>
  
  <p>Method 1</p>
  
  <pre><code>app = Flask(__name__)
  @app.route('/templates', methods=['POST'])
  def original_text_form():
      title = "Summarizer"
      text = request.form['input_text']  # Get text
      max_value = sent_tokenize(text)
      num_sent = int(request.form['num_sentences'])  # Get number of sentence required in summary
      sum1 = summarize()
      summary = sum1.get_summary(text, num_sent)
      print(summary)
  
  
      return render_template("index.html", title = title, original_text = text, output_summary = summary, num_sentences = max_value)
  </code></pre>
  
  <p>Method 2</p>
  
  <pre><code>@app.route('/savetextfile', methods=['POST'])
  
  def saveToFile():
      x = original_text_form
  
      with open('/Users/johnsriskandarajah/Documents/summarizer-master/summary.txt', 'wb') as filehandle:
          filehandle.write(x.summary)
  
  
  
      return render_template("index.html", My_Function=saveToFile)
  </code></pre>