I have a flask service as below:
from flask import Flask, request
import json
import time
app = Flask(__name__)
@app.route("/first", methods=["POST"])
def main():
print("Request received")
func1()
return json.dumps({"status": True})
def func1():
time.sleep(100)
print("Print function executed")
if __name__ == "__main__":
app.run("0.0.0.0", 8080)
So now when I make a request using http://localhost:8080/first
- control goes to main method and it prints
Request receivedand wait forfunc1to get executed and then it returns{"status": True}
But now I don't want to wait for func1 to finish its execution instead it will sent {"status": True} and func1 will continue it's execution.