标签:app 处理器 清除 text get 处理 获取 ssi redirect
@app.context_processor def mycontext(): username = session.get(‘user‘) if username: return {‘username‘:username} else: return {}
{% if username %} <li><a href="#"style="color: red" >{{ username }}</a></li> <li><a href="{{url_for(‘logout‘)}}"style="color: red" >注销</a></li> {% else %} <a href="http://127.0.0.1:5000/login" style="color: red">登录</a> <a href="{{ url_for(‘regist‘)}}" style="color: red">注册</a> {% endif %}
@app.route(‘/logout/‘) def logout(): session.clear() return redirect(url_for(‘hh‘))
{% if username %} <li><a href="#"style="color: red" >{{ username }}</a></li> <li><a href="{{url_for(‘logout‘)}}"style="color: red" >注销</a></li> {% else %} <a href="http://127.0.0.1:5000/login" style="color: red">登录</a> <a href="{{ url_for(‘regist‘)}}" style="color: red">注册</a> {% endif %}
标签:app 处理器 清除 text get 处理 获取 ssi redirect
原文地址:http://www.cnblogs.com/00js/p/7892472.html