推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
1989922yan
V2EX  ›  Python

能给一个 flask-login 的完整例子嘛?已经折腾了一下午

  •  
  •   1989922yan · Mar 2, 2015 · 8246 views
    This topic created in 4229 days ago, the information mentioned may be changed or developed.
    查了不少文档,没弄懂,难道是没有抓住插件开发的技巧?
    先谢过。
    7 replies  •  2015-03-04 13:34:14 +08:00
    Melodic
        1
    Melodic  
       Mar 2, 2015
    没太明白你想怎么开发,是重写flask-login吗?

    我暂时只用到了 下面几个函数
    current_user, login_user, login_required, logout_user

    配合form和数据库,获取/变更用户信息,注册之类的。
    Mirana
        3
    Mirana  
       Mar 2, 2015
    自己写不行吗
    iwillhappy1314
        4
    iwillhappy1314  
       Mar 3, 2015
    为啥不直接用Flask-Security?
    fork3rt
        6
    fork3rt  
       Mar 4, 2015
    @app.route("/login", methods=["GET", "POST"])
    def login():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate():
    req = form.validate_login()
    if req['state_code'] == 0:
    login_user(req['data'])
    else:
    flash(req['message'])
    return redirect('/login')
    return redirect(request.args.get("next") or url_for("/"))
    return render_template("user/login.html", form=form)
    firldlove
        7
    firldlove  
       Mar 4, 2015
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4594 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 08:36 · PVG 16:36 · LAX 01:36 · JFK 04:36
    ♥ Do have faith in what you're doing.