Flask之CBV,flash,Flask-Session,WTForms,DBUtils
阿新 • • 發佈:2018-12-18
CBV
Flask的路由系統有兩種方式 :
@app.route()
app.add_url_rule()
from flask import Flask, views, render_template, redirect, request, session
class LoginView(views.MethodView): def get(self): return render_template("login.html") def post(self): if request.form["name"] == "qwe" and request.form["pwd"] == "qwe": session["user"] = "hd" return redirect("/reg")print(get_flashed_messages("錯誤")) return render_template("login.html") app.add_url_rule("/login", view_func=LoginView.as_view("login"))
flash