Flask view return error “View function did not return a response”

后端 未结 2 1548
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 04:00

I have a view that calls a function to get the response. However, it gives the error View function did not return a response. How do I fix this?



        
2条回答
  •  天命终不由人
    2020-11-22 04:25

    The following does not return a response:

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

    You mean to say...

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

    Note the addition of return in this fixed function.

提交回复
热议问题