V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
onyourroad
V2EX  ›  Python

在使用 Flask 开发时,两个蓝图如果 url_prefix 相同,且在蓝图里的 route() 也相同,那 Flask 会如何处理呢?

  •  
  •   onyourroad · 2019-07-20 21:44:44 +08:00 · 2496 次点击
    这是一个创建于 1712 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如题,在使用 Flask 时突然产生的困惑,有大佬知道吗?
    7 条回复    2019-07-21 18:38:52 +08:00
    summerwar
        1
    summerwar  
       2019-07-20 21:49:47 +08:00 via Android
    试试不就知道了吗?
    summerwar
        2
    summerwar  
       2019-07-20 21:56:29 +08:00 via Android
    按照逻辑,两个蓝图注册有先后,先注册的触发了后面的就不会继续了,就是这样。

    所以路由,特殊的放前面,通用的放后面
    Yourshell
        3
    Yourshell  
       2019-07-20 22:04:48 +08:00
    估计启动不了,抛出 duplicate blueprint prefix 之类
    Hopetree
        4
    Hopetree  
       2019-07-20 22:30:58 +08:00
    试试不就知道了?
    Abbeyok
        5
    Abbeyok  
       2019-07-20 23:59:39 +08:00 via Android
    应该运行出错
    rexyan
        6
    rexyan  
       2019-07-21 07:54:19 +08:00
    endpoint ?
    Tyanboot
        7
    Tyanboot  
       2019-07-21 18:38:52 +08:00
    好像会有个 endpoint 重复的错误, 然后需要自己设置不同的 endpoint.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3506 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:52 · PVG 18:52 · LAX 03:52 · JFK 06:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.