same url_prefix for two flask blueprints same url_prefix for two flask blueprints flask flask

same url_prefix for two flask blueprints


You can move the variable to the url_prefix parameter inside the registering statement :

@main_page.route("/")def home():    return render_template('home.html')app.register_blueprint(main_page, url_prefix='/')@category_page.route('/')def show(category):    return render_template('{}.html'.format(category))        app.register_blueprint(category_page, url_prefix='/<category>')

(it depends on the complexity of the whole pattern, but it may be better to keep the registering statements with the variables close to each function to handle many views.)