question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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 issue

Describe 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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, Jul 10, 2020

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.

0reactions
davidteathercommented, Jul 10, 2020

I don’t have plans to do that right now, but #120 might interest you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found