Inside the bulb drawing, I have:
frontend = Blueprint('frontend', __name__)
and the route to my index function:
@frontend.route('/') def index():
This works fine, but I'm trying to add a subdomain to the route, for example:
@frontend.route('/', subdomain='<var>') def index(var):
But this breaks the application, and the browser spits out (among other things):
werkzeug.routing.BuildError BuildError: ('frontend.index', {}, None)
frontend.index is called in my code in several places in url_for ('frontend.index')
How can I make url_for work when I enable the subdomain? The only thing that is in the documents that I can find, and I think it might be appropriate, is under http://flask.pocoo.org/docs/api/ :
To integrate applications, Flask has a hook to intercept the assembly of the error URL through Flask.build_error_handler. The result of the url_for function in BuildError when the current application does not have a URL for a given endpoint and values. When this happens, current_app calls it build_error_handler if it is not None, which can return a string to use as the result of url_for (instead of using the url_for BuildError exception by default) or re-create the exception. Example:
def external_url_handler(error, endpoint, **values): "Looks up an external URL when `url_for` cannot build a URL."
However, I am new to python (and programming) and cannot figure out where I would put this code, or how to get this function to call when a builderror occurs.
Any insight would be appreciated :)