You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm setting up a basic Flask project with an asynchronous route. I want to fetch information online using the selenium package, and this requires the Flask route to await for the task to finish.
I've been using @swag_from() decorators to document my code and make it easier to work with, here is an idea of what my code looked like:
@website_api.route('/get-data-from-page', methods=['POST'])@swag_from('swagger/get-data-from-page.yml')asyncdefget_data_from_page():
data=req.get_json()
res=awaitcommon.get_data_from_page(data["url"])
returnjson.dumps({ "data": res }), 201
For some reason, this kept throwing: TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a coroutine.
After a couple of hours of trying everything, re-installing Python and both libraries, I found the issue.
Now, this might not be a bug at all, it even might not have anything to do with flasgger and could be a problem is Flask directly. But the README of this project says to do it like so:
I'm setting up a basic Flask project with an asynchronous route. I want to fetch information online using the
selenium
package, and this requires the Flask route to await for the task to finish.I've been using
@swag_from()
decorators to document my code and make it easier to work with, here is an idea of what my code looked like:For some reason, this kept throwing: TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a coroutine.
After a couple of hours of trying everything, re-installing Python and both libraries, I found the issue.
This causes the error:
This doesn't:
(Note the order of the decorators)
Now, this might not be a bug at all, it even might not have anything to do with flasgger and could be a problem is Flask directly. But the README of this project says to do it like so:
Maybe a switch between those two lines in the README and any documentation would be interesting?
The text was updated successfully, but these errors were encountered: