當前位置: 首頁>>代碼示例>>Python>>正文


Python flask.flash方法代碼示例

本文整理匯總了Python中flask.flash方法的典型用法代碼示例。如果您正苦於以下問題:Python flask.flash方法的具體用法?Python flask.flash怎麽用?Python flask.flash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask的用法示例。


在下文中一共展示了flask.flash方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: skip

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def skip(self):
        if g.user is None:
            self.logger.info('[%s][%s] anonymous skip', g.user, self.name)
            return redirect(url_for(self.name + '.index'))

        g.user.lock()
        if not self.can_skip():
            g.user.unlock()
            self.logger.warning('[%s][%s] skip() but can\'t skip', g.user, self.name)
            return render_template('forbidden.html'), 403

        g.user.setstate(self, 'skipped')
        g.user.commit()
        self.logger.info('[%s][%s] skipped', g.user, self.name)

        flash(u"Te has saltado el nivel %d" % self.number)
        try:
            next = self.route_.levels[self.routeidx+1]
            return redirect(url_for(next.name + '.index'))
        except IndexError:
            alldone = all([l.state() == 'solved' for r in routes for l in r.levels])
            self.logger.info('[%s][%s] last level (alldone=%r)', g.user, self.name, alldone)
            return render_template('alldone.html', alldone=alldone, level=self) 
開發者ID:marcan,項目名稱:hackit,代碼行數:25,代碼來源:level.py

示例2: is_admin_sess_timedout

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def is_admin_sess_timedout(function):
    """
    Decorator that checks if the admin session has timeout.
    If not true redirect to the login page
    """

    @wraps(function)
    def check_session_timeout(*args, **kwargs):
        if admin_session_timedout():
            if flask.request.method == "POST":
                flask.flash("Action canceled, try it again", "error")
            return flask.redirect(
                flask.url_for("auth_login", next=flask.request.url)
            )
        return function(*args, **kwargs)

    return check_session_timeout 
開發者ID:Pagure,項目名稱:pagure,代碼行數:19,代碼來源:decorators.py

示例3: auth_logout

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def auth_logout():  # pragma: no cover
    """ Method to log out from the application. """
    return_point = flask.url_for("ui_ns.index")
    if "next" in flask.request.args:
        if pagure.utils.is_safe_url(flask.request.args["next"]):
            return_point = flask.request.args["next"]

    if not pagure.utils.authenticated():
        return flask.redirect(return_point)

    logout()
    flask.flash("You have been logged out")
    flask.session["_justloggedout"] = True
    return flask.redirect(return_point)


# pylint: disable=unused-argument 
開發者ID:Pagure,項目名稱:pagure,代碼行數:19,代碼來源:flask_app.py

示例4: confirm_user

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def confirm_user(token):
    """ Confirm a user account.
    """
    user_obj = pagure.lib.query.search_user(flask.g.session, token=token)
    if not user_obj:
        flask.flash("No user associated with this token.", "error")
    else:
        user_obj.token = None
        flask.g.session.add(user_obj)

        try:
            flask.g.session.commit()
            flask.flash("Email confirmed, account activated")
            return flask.redirect(flask.url_for("auth_login"))
        except SQLAlchemyError as err:  # pragma: no cover
            flask.flash(
                "Could not set the account as active in the db, "
                "please report this error to an admin",
                "error",
            )
            _log.exception(err)

    return flask.redirect(flask.url_for("ui_ns.index")) 
開發者ID:Pagure,項目名稱:pagure,代碼行數:25,代碼來源:login.py

示例5: feedback

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def feedback():
  if not config.CONFIG_DB.feedback_email:
    return flask.abort(418)

  form = FeedbackForm(obj=auth.current_user_db())
  if not config.CONFIG_DB.has_anonymous_recaptcha or auth.is_logged_in():
    del form.recaptcha
  if form.validate_on_submit():
    body = '%s\n\n%s' % (form.message.data, form.email.data)
    kwargs = {'reply_to': form.email.data} if form.email.data else {}
    task.send_mail_notification('%s...' % body[:48].strip(), body, **kwargs)
    flask.flash('Thank you for your feedback!', category='success')
    return flask.redirect(flask.url_for('welcome'))

  return flask.render_template(
    'feedback.html',
    title='Feedback',
    html_class='feedback',
    form=form,
  ) 
開發者ID:lipis,項目名稱:github-stats,代碼行數:22,代碼來源:feedback.py

示例6: oauth_callback

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def oauth_callback():
    """OAuth handshake callback."""
    if 'request_token' not in flask.session:
        flask.flash(u'OAuth callback failed. Are cookies disabled?')
        return flask.redirect(flask.url_for('index'))

    consumer_token = mwoauth.ConsumerToken(
        app.config['CONSUMER_KEY'], app.config['CONSUMER_SECRET'])

    try:
        access_token = mwoauth.complete(
            app.config['OAUTH_MWURI'],
            consumer_token,
            mwoauth.RequestToken(**flask.session['request_token']),
            flask.request.query_string)

        identity = mwoauth.identify(
            app.config['OAUTH_MWURI'], consumer_token, access_token)
    except Exception as e:
        app.logger.exception('OAuth authentication failed')

    else:
        flask.session['access_token'] = dict(zip(
            access_token._fields, access_token))
        print('//////// ACCESS_TOKEN')
        print(access_token)
        flask.session['username'] = identity['username']

    next_url = flask.request.args.get('next_url') or flask.url_for('get_random_edit')
    return flask.redirect(next_url) 
開發者ID:dissemin,項目名稱:oabot,代碼行數:32,代碼來源:app.py

示例7: index

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def index():
    # return flask.send_from_directory('./static/', 'index.html')
    flask.flash(str((fan.speed, fan.brightness)))
    return flask.render_template("index.html")


# Light Functions 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:9,代碼來源:flask_app.py

示例8: toggle_light

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def toggle_light():
    fan.light_toggle()
    flask.flash("Toggling Light")
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例9: light_off

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def light_off():
    fan.light_powered_on = False
    flask.flash("Turning Light Off")
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例10: light_on

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def light_on():
    fan.light_powered_on = True
    flask.flash("Turning light On")
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例11: light_level

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def light_level(level):
    fan.brightness = int(level)
    flask.flash("Set light level to {}".format(level))
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例12: dec_light

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def dec_light():
    fan.dec_brightness()
    flask.flash("Decreased Light Level")
    return flask.redirect(flask.url_for("index"))


# Fan Functions 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:9,代碼來源:flask_app.py

示例13: inc_speed

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def inc_speed():
    fan.inc_speed()
    flask.flash("Increased Fan Speed")
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例14: dec_speed

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def dec_speed():
    fan.dec_speed()
    flask.flash("Decreased Fan Speed")
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py

示例15: set_speed

# 需要導入模塊: import flask [as 別名]
# 或者: from flask import flash [as 別名]
def set_speed(speed):
    fan.speed = int(speed)
    flask.flash("Set fan speed to {}".format(speed))
    return flask.redirect(flask.url_for("index")) 
開發者ID:TomFaulkner,項目名稱:SenseMe,代碼行數:6,代碼來源:flask_app.py


注:本文中的flask.flash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。