9

I feel stupid to ask this here

I am getting this error in flask
view didn't return a valid response error. The function either returned None or ended without a return statement.

Comments
  • 2
    I'd check out the browser's development tools and see what request is it performing. The only way I see where a view might be returning None would be if the request method of /result wasn't a GET.
  • 0
    @ethernetzero it is GET
    I checked that
  • 1
    @Ganofins Now, if your view only accepts GET requests, why checking for the request method inside of it? It should be GET or 405 Method Not Allowed all the time.
  • 0
    @ethernetzero does that really matter right now?
  • 1
    @Ganofins Removing the if would at least remove a branching path in your view that can result in it not returning anything. It's a start.
  • 0
    @ethernetzero actually before that I had both POST and GET in the methods argument, that's why it's there
  • 0
    @rooter yeah I am on debug mode and /result?junk=pony didn't help
  • 1
    1. Remove request type checking. Thats pointless as @ethernetzero.

    2. Does browser redirects you to /result?

    3. Try returning just "hello". Does it simply prints? I don't know flask. Just want to check if returning a value works like you expected.

    4. Try request.args.get("junk")
  • 0
    @hack yes the browser redirects me to result

    yes it prints hello

    and args worked

    Thanks :)
  • 2
    @Ganofins no problem :) just to clarify, a quick search revealed request.form is used for POST data and request.args is used for GET data. Just keep that in mind :)
  • 0
Add Comment