我想使用flash
来显示一条消息,但这样做会引发异常。下面的代码演示了错误,并且如果删除对flash
的调用,它可以正常工作。我该如何修复这个错误?
from flask import Flask, flash
app = Flask(__name__)
@app.route('/')
def index():
flash('Entered')
return 'Completed'
app.run(debug=True)
RuntimeError: the session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.