Flask: How to use the multi url_prefix with same Blueprint?

Created on 7 Jul 2013  路  3Comments  路  Source: pallets/flask

bp = Blueprint(__name__, __name__, url_prefix=("/profile", "/personal/profile"), static_folder="static")

@bp.route("/main", methods=["GET"])
def page():
    pass

All 3 comments

multi url as in - using a regex?

it's also possible to just assign multiple instances of the blueprint with different url_prefixes. (i've had to do this to assign the same blueprint to run with a url prefix, and with no prefix on a subdomain)

bp1 = Blueprint(__name__, __name__, url_prefix="/profile1", static_folder="static")
bp2 = Blueprint(__name__, __name__, subdomain="<subdomain>", url_prefix="/", static_folder="static")

using a regex:

bp1 = Blueprint(__name__, __name__, url_prefix="/profile<:profile_id>", static_folder="static")
@bp.route("/main", methods=["GET"])
def page(profile_id):

BTW - use stackoverflow for this kinda stuff

This is not StackOverflow...

:+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lnielsen picture lnielsen  路  3Comments

ghost picture ghost  路  3Comments

jab picture jab  路  4Comments

fb picture fb  路  5Comments

ghostbod99 picture ghostbod99  路  4Comments