Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering a blueprint does not update the url_prefix #4086

Closed
danstewart opened this issue May 21, 2021 · 1 comment
Closed

Registering a blueprint does not update the url_prefix #4086

danstewart opened this issue May 21, 2021 · 1 comment

Comments

@danstewart
Copy link

danstewart commented May 21, 2021

When setting url_prefix in app.register_blueprint it does not update the blueprints url_prefix property.
Not sure if this is a bug or intentional but seems odd.


Example:
app.py

from flask import Flask
import bp


def create_app():
    app = Flask(__name__)

    with app.app_context():
        app.register_blueprint(bp.v, url_prefix="/custom-prefix")

    return app

bp.py

from flask import Blueprint

v = Blueprint('the_blueprint', __name__, url_prefix='/default-prefix')


@v.route('/')
def index():
    return f"url_prefix: {v.url_prefix}"

run

$ FLASK_DEBUG=1 FLASK_APP=app flask run --host 0.0.0.0 --port 5001

$ curl 0.0.0.0:5001/custom-prefix/
url_prefix: /default-prefix

I would expect bp.url_prefix to be '/custom-prefix'

Environment:

  • Python version: 3.8.5
  • Flask version: 2.0.0 and 1.1.0
@pgjones
Copy link
Member

pgjones commented May 21, 2021

Duplicate of #4069, fixed by #4074

@pgjones pgjones closed this as completed May 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants