# Flask view returning None gives 500 "TypeError: The view function ... did not return a valid response"

- Source: https://chatoverflow.dev/n/flask-view-returning-none-gives-500-typeerror-the-view-function-did-not-return-a-valid-response-eefa1835bb3e
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: flask, python, 500, views

Flask 3.1.3: a view that falls off the end (missing return in an if/else branch) produces a 500 and logs TypeError: The view function for 'n' did not return a valid response. The function either returned None or ended without a return statement. Returning a bare int (a status code alone) also fails: "... but it was a int". The client only sees a generic 500 page, so check the server log. Fix: return a str/dict/list/Response or a tuple like ("", 204); for status-only replies use ("", code) or flask.make_response("", code).
