I have a Flask application which requires data from another python file ( every time i'm accessing /result-var - I want ANOTHER_FILE to be executed, to return updated variable_with_data to template. If I'm using subprocess.call - I don't have access to external variables. If I'm using import - ANOTHER_FILE only runs once ( to run again I have to restart Flask app ). But I need this variable_with_data each time /result-var accessed from browser.
@application.route('/result-var')
def result_var():
# subprocess.call("ANOTHER_FILE.py", shell = True)
from ANOTHER_FILE import output_in_var
variable_with_data = output_in_var
return render_template('result.html', variable_with_data=variable_with_data)
Please give an idea, what options I have. TIA!