I am using flask for serving a post request. I have the following code:
from flask import Flask
from flask import request
from another_file import Another_Class_Somewhere_Else
app = Flask(__name__)
od = ""
@app.route("/call_my_func", methods=['GET', 'POST'])
def hello():
res = od.some_func()
return res
if __name__ == "__main__":
global od
my_param = "dummy_string"
od = Another_Class_Somewhere_Else(my_param)
app.run(debug=True, host='10.0.10.15')
As you can see above, my objective is to create an object of another class only once. Then use this object to run a method of the another class every time we get a post request?
What is wrong with the method above because it doesn't seem to create the object once.