8

The blueprint is defined as

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

I have an index route defined as

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

and another route defined as

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

The problem is that when I access the url for e.g.

http://localhost/en/us/m1

it always sends me to

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

But if I access

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

it keeps me on

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

I have even tried playing with the strict_slashes option and turned it OFF , but has no effect.

It doesn't seem to work, even thought it works for all other URLs of the blueprint for e.g. '/abc'

Another thing I noticed was that if I don't use a blueprint and define a '/' route on the app itself with strict_slashes = False, it works as expected !

5
  • is abc path param? Commented Apr 12, 2017 at 7:23
  • 1
    The same question. Maybe it will be useful. Commented Apr 12, 2017 at 8:25
  • actually you're telling the index route to match the url_prefix + '/'. Try to remove the slash and see if its working. Also try to make a request via curl, because, you know, browser has a cache. Commented Apr 13, 2017 at 7:21
  • Tried everything, doesn't seem to fix. Commented Apr 14, 2017 at 8:42
  • I have the same question, and think it's distinct from the thread linked by @DanilaGranchar. I think the difference between the url being a the index where the only content of the route itself is /, and a abc route which has other text to add or remove slashes from. It seems like you should be able to ask the bp to apply the index slash non-strictly but didn't find a solve when looking. Commented Aug 18, 2019 at 14:19

1 Answer 1

4

Try

@publicweb_bp.route('', strict_slashes=False)

This works for me in Flask v1.1.1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.