其他分享
首页 > 其他分享> > 233.9.flask-闪现

233.9.flask-闪现

作者:互联网

1.闪现

# coding=utf-8
from flask import Flask, session, flash, get_flashed_messages

app = Flask(__name__)
app.config.from_object("settings.DevelopmentConfig")


@app.route("/index", methods=["POST", "GET"])
def index():
    session["msg"] = "登录事变"
    flash("hello world")  # 存储临时信息, 通过session实现的
    flash("分配", category="a1")  # 设置消息分类
    flash("分配2", category="a2")
    return "试图函数index1"


@app.route("/index2", methods=["POST", "GET"])
def index2():
    msg = session.pop("msg")
    print(msg)
    print(get_flashed_messages())
    print(get_flashed_messages(category_filter="a2"))
    return "试图函数index2"


if __name__ == '__main__':
    app.run()

标签:__,category,flask,app,flash,闪现,233.9,session,msg
来源: https://www.cnblogs.com/liuzhanghao/p/16337532.html