Flask 蓝图索引 URL 不断添加尾部斜杠

Sto*_*orm 8 python werkzeug flask python-3.x

蓝图定义为

publicweb_bp = flask.Blueprint('publicweb', __name__, url_prefix='/<lang_code>/<country_code>/<market_code>')
Run Code Online (Sandbox Code Playgroud)

我有一个索引路由定义为

@publicweb_bp.route('/', strict_slashes = False)
def pp_index():
    return 'Hello'
Run Code Online (Sandbox Code Playgroud)

另一条路线定义为

@publicweb_bp.route('/abc', strict_slashes = False)
def pp_index():
    return 'Abcdefg :P'
Run Code Online (Sandbox Code Playgroud)

问题是当我访问例如的网址时

http://localhost/en/us/m1

它总是把我送到

http://localhost/en/us/m1/

但如果我访问

http://localhost/en/us/m1/abc

它让我继续下去

http://localhost/en/us/m1/abc

我什至尝试使用 strict_slashes 选项并将其关闭,但没有效果。

它似乎不起作用,即使它适用于蓝图的所有其他 URL,例如“/abc”

我注意到的另一件事是,如果我不使用蓝图并使用 strict_slashes = False 在应用程序本身上定义“/”路线,它会按预期工作!

Ian*_*Ian 4

尝试

@publicweb_bp.route('', strict_slashes=False)
Run Code Online (Sandbox Code Playgroud)

这在 Flask v1.1.1 中对我有用