烧瓶蓝图索引URL不断添加斜杠

问题描述 投票:3回答:1

该蓝图定义为

publicweb_bp = flask.Blueprint('publicweb', __name__, url_prefix='/<lang_code>/<country_code>/<market_code>')

我将索引路由定义为

@publicweb_bp.route('/', strict_slashes = False)
def pp_index():
    return 'Hello'

和另一条定义为]的路线>

@publicweb_bp.route('/abc', strict_slashes = False)
def pp_index():
    return 'Abcdefg :P'

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

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定义'/'路由,则它将按预期工作!

蓝图定义为publicweb_bp = flask.Blueprint('publicweb',__name__,url_prefix ='/ / / ')我有一个索引路由定义为@ ...

python python-3.x flask werkzeug
1个回答
0
投票

尝试

@publicweb_bp.route('', strict_slashes=False)
© www.soinside.com 2019 - 2024. All rights reserved.