Menu Close

How to fix Python Flask view returning error “View function did not return a response”?

Sometimes, we want to fix Python Flask view returning error "View function did not return a response"

In this article, we’ll look at how to fix Python Flask view returning error "View function did not return a response".

How to fix Python Flask view returning error "View function did not return a response"?

To fix Python Flask view returning error "View function did not return a response", we should return a response in our view.

For instance, we write

@app.route('/hello', methods=['GET', 'POST'])
def hello():
    return hello_world()

to return the value returned by hello_world as the response in the hello view function.

Conclusion

To fix Python Flask view returning error "View function did not return a response", we should return a response in our vie

Posted in Python, Python Answers