0

It may look very odd, but this is what I want to achieve exactly, it is not related with blueprints or add prefix to all routers. thanks!

davidism
  • 121,510
  • 29
  • 395
  • 339
X.C.
  • 703
  • 9
  • 18

1 Answers1

1

You can define your own:

# url_for_custom.py
import flask

def url_for(endpoint, **values):
    url = flask.url_for(endpoint, **values)
    if not values.get('_external', False):
        url = '/foo' + url
    return url

If you wish to change it globally, you can monkey-patch some time early on:

# __init__.py
import flask
from url_for_custom import url_for

flask.url_for = url_for

Although it's perhaps better to simply import and use your own implementation.

dmitrybelyakov
  • 3,709
  • 2
  • 22
  • 26