I'm new at Flask. I try to pass a parameter from the main, but it doesn't work. Hope somebody can help me. Here is my code
from flask import Flask, render_template, request
import controllFlask
import pickle
app = Flask(__name__) # creates a flask object
import subprocess
@app.route('/', methods=['GET', 'POST'])
def ner():
'''controlls input of Webapp and calls proccessing methods'''
knownEntities = pickle.load( open( "entityDictThis.p", "rb" ))
print("loades")
content = ""
if request.method == 'POST':
testText = (request.form['input'])
app.ma = controllFlask.controll(testText, knownEntities)
subprocess.call("controllFlask.py", shell=True)
with open("test.txt", "r") as f:
content = f.read()
return render_template("ner.jinja2", content=content)
def flaskApp():
app.debug = True
app.run()
I want to open entityDictThis in flaskApp and give it to the ner-function. Because I hope in this way it loads only one time. At the moment it loads every time the page is reloaded and it takes very long. Is there a easy way?