我刚刚开始学习烧瓶,但是遇到了405错误
select "ItemId",
max("Date"),
"Price"
from "Products"
group by "ItemId"
main.html是
# Weather App using Flask
## imports
import main
from flask import Flask
from flask import render_template
from flask import request
app = Flask(__name__)
## initalisation
@app.route('/')
def main_page(methods=["GET", "POST"]):
if request.method == "POST":
city = request.form("city")
print(city)
return render_template("main.html")
if __name__ == "__main__":
app.run(debug=True)
POST在方法参数中,但我无法查明错误的位置
预先感谢
答案 0 :(得分:1)
与其在视图函数的参数中没有methods
列表,还应将其放在装饰器后面的方括号中,如下所示:
@app.route('/',methods=["GET","POST"])
def main_page():
# your view function
这将允许通过GET和POST请求访问此路由。