[英]RuntimeError Error in Flask python on Post
我的代碼:
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:嘗試在相關上下文之外訪問應用程序
您需要在代碼中實例化應用程序。 在您的導入下添加此行:
app = Flask(__name__)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.