Flask's route decorator gives a nice syntax, but it goes against some ideal best practices: * Imports shouldn't have side-effects (like registering functions with flask). * You shouldn't use globals (like the flask app). * Objects (such as the flask app) should be immutable whenever possible. None of these are hard-and-fast rules, and Python code has a tendency to give up purity in favor of syntax, so it's certainly…
>Imports shouldn't have side-effects (like registering functions with flask). Imports don't have side-effects. Using Flask's route decorators has. >You shouldn't use globals (like the flask app). The Flask app is just as much a global as any other class instance in any OOP language. Whether you make it a module-level object or not is your choice. >Objects (such as the flask app) should be immutable whenever possible.…
All of the examples that I've seen (including the Flask quickstart guide, the linked post, and everything I could find on http://flask.pocoo.org/community/poweredby/ ) work by assigning the Flask app to a module-level variable (i.e. a global), then using that global at import time for all @app.route usages, so my assumption has been that that's the encouraged style. It at least seems to be pretty common. But I guess none of those examples are very big (only a few split the request handlers across multiple files), so they didn't get to a point where blueprints would be especially useful.
(Also, to be clear, when I say "imports shouldn't have side-effects", what I mean is that top-level code (which runs at import time) should ideally have no side effects.)