Answer the question
In order to leave comments, you need to log in
Flask, how to call a method and without waiting for its response return the response in jsonify?
There is a route, upon request of which the draw ()
method should be called, which in turn draws a picture using the Pillow library.
The problem is that all this rendering takes about 10 seconds (features of the e-ink display driver)
from draw import Drawing
@app.route(api_url('/<string:route>'), methods=['POST'])
def router(route):
try:
req_data = request.json
if route == 'weather':
Drawing().draw()
return jsonify(status='Draw'), 200
else:
return abort(404)
except Exception as e:
logError(e)
return abort(400)
Answer the question
In order to leave comments, you need to log in
It is necessary to separate the flies from the cutlets.
In the route, raise the "redraw needed" flag. As a separate thread (and even better - as a separate service), monitor this flag and react accordingly. Otherwise, you will run into problems as soon as more than 1 client accesses the route.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question