[BUG] - TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a coroutine.
See original GitHub issueDescribe the bug
I am trying to insert this library in a flask server so I can get tiktok data from Unity3D for example making web requests to my flasks server and getting raw mp4 url or thumbnail url I can play on unity. When I run the flask server and make the get petition it shows this error:
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a coroutine.
The buggy code
@app.route('/get_trending')
async def get_trending():
results = 10
trending = api.trending(count=results)
for tiktok in trending:
# Prints the text of the tiktok
return jsonify(tiktok)
print(len(trending))
return 'OK'
Expected behavior
Return a json answer that is a dictionary of the tiktok.
Error Trace (if any)
RuntimeError: There is no current event loop in thread ‘Thread-1’.
# Error Trace Here
Desktop (please complete the following information):
- OS: [e.g. Windows 10] Debian 10
- TikTokApi Version [e.g. 3.3.1] - 3.3.1
Additional context I know there’s an api running on rapidApi but I want to host it myself.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
view function did not return a valid response. The return type ...
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI...
Read more >ValueError: View Function Did Not Return a Response - Sentry
The Solution All Flask views must return a value, usually a Response object. If the flask view throwing the error accepts GET and...
Read more >builtins.TypeError TypeError: 'dict' object is not callable The ...
python ypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or...
Read more >API Documentation — flask-jwt-extended 4.4.4 documentation
This decorator sets the callback function for returning a custom response when a valid and non-fresh token is used on an endpoint that...
Read more >Flask REST API Error: The view function did not return a valid ...
TypeError : The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Issue-Label Bot is automatically applying the label
bug
to this issue, with a confidence of 0.89. Please mark this comment with 👍 or 👎 to give our bot feedback!Links: app homepage, dashboard and code for this bot.
I don’t have plans to do that right now, but #120 might interest you.