def hello(): name=request.form['yourname'] keywordList = abstractToKeyword(name) textOutput = keywordsToPapers(keywordList) formatted = "" for i in xrange(5): formatted += textOutput[i*10]+"\n" return render_template('form_action.html', name=formatted)
# main aka link between web and python scripts... from keywordsToPapers import keywordsToPapers from abstractToKeyword import abstractToKeyword import cgi from flask import Flask app = Flask(__name__) # take input from front end and pass to aTK form = cgi.FieldStorage() title = form.getvalue('searchbox') # pass aTK's keywords to kTP keywordList = abstractToKeyword(title) textOutput = keywordsToPapers(keywordList) # TESTING..... print textOutput to file textFile = open('output_cows.txt', 'w') textFile.write(textOutput) textFile.close() # use flask to create the results page @app.route('/') def output(): return textOutput if __name__ == '__main__': app.run()