from flask import url_for, request from app import app def url_for_other_page(page): args = request.view_args.copy() args['page'] = page return url_for(request.endpoint, **args) app.jinja_env.globals['url_for_other_page'] = url_for_other_page # @app.context_processor # def register_method(): # def url_for_other_page(page): # args = request.view_args.copy() # args['page'] = page # return url_for(request.endpoint, **args) # return dict(url_for_other_page=url_for_other_page)