I was creating a flask application and tried to call a python function in which I wanted to invoke some javascript function/code regarding the HTML template that I returned on the initial app.route('/')
If the user did something, then I called another function that should invoke or call a js function I have tried looking everywhere but I cannot make any sense of the solutions.
Here is the structure of my code:
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
#verify if the file is valid
#here invoke js to do something (for example flash("test"))
return '''
<!doctype html>
<title>Upload new File</title>
<h1>Upload new File</h1>
<form method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>
'''