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.
Method 1
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)
Method 2
@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)
summarize()is quite unclear? are you trying to setup a file cache to exchange data between functions? why not a database model?