How to use the flask.redirect function in Flask

To help you get started, we’ve selected a few Flask examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plastboks / Flaskmarks / flaskmarks / views / auth.py View on Github external
def login():
    if g.user.is_authenticated():
        return redirect(url_for('marks.allmarks'))
    form = LoginForm()
    """
    POST
    """
    if form.validate_on_submit():
        u = User.by_uname_or_email(form.username.data)
        if u and u.authenticate_user(form.password.data):
            u.last_logged = datetime.utcnow()
            db.session.add(u)
            db.session.commit()
            flash('Welcome %s.' % (u.username),
                  category='success')
            login_user(u, remember=form.remember_me.data)
            return redirect(url_for('marks.allmarks'))
        else:
            flash('Failed login for %s.' % (form.username.data),
github simon987 / od-database / views.py View on Github external
def enqueue():
        if not config.CAPTCHA_SUBMIT or captcha.verify():

            url = os.path.join(request.form.get("url"), "")
            message, msg_type = try_enqueue(url)
            flash(message, msg_type)

            return redirect("/submit")

        else:
            flash("<strong>Error:</strong> Invalid captcha please try again", "danger")
            return redirect("/submit")
github livro-aberto / BookCloud / application / views / threads.py View on Github external
print('Email should be sent to: ' + str(recipients))
            print(message)
        else:
            with mail.connect() as conn:
                for user in recipients:
                    user_obj = User.get_by_name(user)
                    subject = _('Thread: ') + new_thread.title
                    msg = Message(recipients=[user_obj.email],
                                  subject=subject,
                                  html=message)
                    conn.send(msg)
                flash(_('Emails sent to user(s) {}')
                      .format(str(recipients)))
        flash(_('New thread successfully created'), 'info')
        if 'return_url' in request.args:
            redirect(urllib.unquote(request.args['return_url']))
        else:
            return redirect(url_for('threads.query_thread',
                                    project=project.name,
                                    thread_id=new_thread.id))
    return render_template('threads/newthread.html', form=form)
github happyte / flask-blog / app / main / views.py View on Github external
def show_all():
    response = make_response(redirect(url_for('main.index')))
    response.set_cookie('show_followed','',max_age=30*24*60*60)    # 通过cookie的值判断点击了all还是followed
    return response
github Polsaker / throat / app / views / auth.py View on Github external
def confirm_registration():
    if current_user.is_authenticated:
        return redirect(url_for('home.index'))
    return engine.get_template('user/check-your-email.html').render({'reason': 'registration'})
github zpriddy / ZP_EchoSmartThingsPy / echopy.py View on Github external
@app.route(settings.url_root + "/nest/auth",methods = ['GET','POST'])
def nest_auth():
	if request.method == 'GET':
		return echopy_doc.nest_auth_page(nestApp.get_nest_user_count())

	if request.method == 'POST':
		alexaId=request.form['AlexaID'].replace(' ','')
		clientEmail=request.form['Email'].replace(' ','')

		auth_uri = nestApp.nestAuth(alexaId, clientEmail)
		#auth_uri = myApp.STAlexaAuth(alexaId,clientId,clientSecret,clientEmail)
		return redirect(auth_uri)
github PininQ / Flask_movie_project / app / home / views.py View on Github external
def logout():
    session.pop("user", None)
    session.pop("user_id", None)
    # 重定向到home模块下的登录
    return redirect(url_for('home.login'))
github abrt / faf / src / webfaf / utils.py View on Github external
def decorated_view(*args, **kwargs):
        if g.user is None:
            return redirect(url_for('login.do_login', next=request.url))

        if not g.user.admin:
            abort(403)

        return func(*args, **kwargs)
    return decorated_view
github avilaton / gtfseditor / app / auth / views.py View on Github external
def logout():
    logout_user()
    return redirect(url_for('auth.login'))