我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用app.app.before_request()。
def before_request(): flask.g.user = current_user
def before_request(): g.user = current_user
def before_request(): g.user = current_user g.plex = p if current_user is not None and hasattr(current_user, "locale") and current_user.locale not in ['de','en']: flash(_("You are useing an incomplete translation please help! %(link)s", link="https://www.transifex.com/projects/p/plexivity/"), "info") if not db.session.query(models.User).first() and not (request.url_rule.endpoint in ["setup", "static"]): return redirect(url_for("setup"))
def before_request(): pass
def before_request(): database.connect()
def before_request(): if current_user.is_authenticated() and current_user.is_anonymous() is False: current_user.ping() if not current_user.confirmed and request.endpoint and request.endpoint[:4] == 'view' and request.endpoint != 'static': return redirect(url_for('unconfirmed'))
def before_request(): if len(request.path) < 2: return split = request.url.split('?', 1) if split[0].endswith('/'): split[0] = split[0][:-1] if len(split) < 2: return redirect(split[0]), 301 else: return redirect('?'.join(split)), 301
def before_request(): g.user = current_user if g.user.is_authenticated: g.user.last_seen = datetime.utcnow() db.session.add(g.user) db.session.commit()
def before_request(): g.shrek = get_random_shrek()
def before_request(): #print current_user.is_authenticated #prn_obj(current_user) g.user = current_user #print g.user.is_authenticated #prn_obj(g.user)