線上報警 5xx 錯誤,查看日志發現報這個錯,
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
這個方法沒有有效的返回結果
頁面報這個錯誤
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
服務器遇到內部錯誤,無法完成您的請求。服務器過載或應用程序出錯。
代碼部分
1 # flask 請求不可以沒有返回值 2 # The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. 3 import flask 4 5 from flask import Flask, request 6 7 app = Flask(__name__) 8 9 10 @app.route('/func') 11 # 展示數據 12 def func(): 13 return # 這塊有問題 14 # TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement. 15 16 if __name__ == "__main__": 17 app.run(host='127.0.0.1',port='9090')
修改方法,加個返回值就好了。