I have to take input from a web page in python. I am using flask for that. I want to return the input it got. I want to call that flask function into another file that does not use flask, just python file. Example: the following code is in the inputpage.py
@app.route('/topic', methods=['GET', 'POST'])
def topic_input():
res = None
if request.method == 'POST':
if not request.form['t1'] and not request.form['t2'] :
res = 'please fil the form'
# print(result)
else:
try:
term = request.form['t1']
t2 = int(request.form['t2'])
res='Good'
except BaseException as error:
res = 'error: {}'.format(error)
# print(result)
#return render_template('topic.html', articles=res_dic, result=res)
return(term,t2)
In another file lets say test.py I try to call the above function ,
from inputpage import topic
print(topic_input())
But I get the following error: raise RuntimeError(_request_ctx_err_msg) RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed an active HTTP request. Consult the documentation on testing for information about how to avoid this problem.
I wonder how I can do such thing. Your help is appreciated :)