请求管道,登录前的验证,否则重定向到登录页面。
1 # coding: utf8 2 from flask import render_template, request, g, session, redirect, url_for, jsonify 3 from pycode import app 4 from master.menu import get_master_menu 5 6 7 @app.before_request 8 def before_request(): 9 g.menu1 = [('index', 'WMS'), ('master', '基础'), ('inbound', '入库'), ('outbound', '出库'), ('inventory', '库存')] 10 user = session.get('user', None) 11 if 'master' in request.path: 12 g.submenu = get_master_menu() 13 if user is None and request.endpoint != 'index' and request.endpoint != 'login' and request.endpoint != 'static': 14 return redirect(url_for('index'))