I have made an api with restplus
from flask_restplus import Namespace, Resource, fields
from flask import request
from flask_restplus import abort
api = Namespace('myproject', description='My API')
@api.route('/run')
class MyProject(Resource):
@api.doc(params={'name':'name'})
def post(self):
#doing stuff
return {'status':'started'}
The point of this route is to run another function and return {'status':'started'} immediatly without waiting for the function to end.
I've found this https://stackoverflow.com/a/51013358/1540114 but I have trouble using it in my project from what I understood the AfterResponse is a middleware that I can apply to my route
I tried using it like this
....
api = Namespace('myproject', description='My API')
AfterResponse(api)
@api.after_response
def say_hi():
print("hi")
@api.route('/run')
class MyProject(Resource):
....
but it gave me an error stating that api doesn't have a wsgi_app property