I have a complex flask application with multiple instances of Flask submitted using werkzeug middleware. And in this situation, I have two questions related not to url_for, but to managing the context of the jars.
1) How to create a URL from one application to another?
2) The main thing is how to create a URL for a specific application without the app_context application. For example, I need to create some URL by import time or by celery order. I tried to wrap on top of all the application instances and override url_for as
def url_for(self, *args, **kwargs): with self.app.app_context(): return url_for(*args, **kwargs)
but I just got the following error: "The application was unable to create a URL adapter for request-independent URL generation. Perhaps you can fix this by setting the SERVER_NAME configuration variable." Any suggestions?
Update: my solution for the second problem was correct, just need to add SERVER_NAME, but the first one is still open
source share