my code:
from flask import Flask, render_template,request, redirect
@app.route("/wait", methods=['GET', 'POST'])
def wait():
print(5)
return render_template("wait")
@app.route("/", methods=['GET', 'POST'])
def index():
if request.method == 'POST':
data = request.form
print(data["theme"])
print(data["subreddit"])
return redirect("/wait")
else:
return render_template("index.html")
我的错误:RuntimeError: Attempt to access app outside of a relevant context
你需要在你的代码中实例化app。在导入文件下面添加这一行:
app = Flask(__name__)