推荐学习书目
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
sasic
V2EX  ›  Python

[Flask] auth 蓝本外,比如 main 里如何引入 @login_required

  •  
  •   sasic · Jan 15, 2018 · 2626 views
    This topic created in 3045 days ago, the information mentioned may be changed or developed.
    main/views.py

    from flask_login import login_required
    @login_required
    @main.route('/upload', methods=['GET', 'POST'])
    def upload():
    ....
    2 replies    2018-01-15 11:35:58 +08:00
    Mrkon
        1
    Mrkon  
       Jan 15, 2018
    顺序错了?
    from flask_login import login_required
    @main.route('/upload', methods=['GET', 'POST'])
    @login_required
    def upload():
    ....
    sasic
        2
    sasic  
    OP
       Jan 15, 2018
    是的,装饰器和路由位置反了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3091 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
    ♥ Do have faith in what you're doing.