A view function may be the code you compose to respond to needs to the application

A view function may be the code you compose to respond to needs to the application

Flask makes use of patterns to match the incoming request Address to the view which should handle it. The view comes back data that Flask turns into a outbound reaction. Flask also can get one other way and create A url to a view according to its title and arguments.

Create a Blueprint

A Blueprint is just a real means to arrange a team of associated views along with other rule. Instead of registering views as well as other rule straight with a credit card applicatoin, they’ve been registered with a blueprint. Then your blueprint is registered utilizing the application when it’s obtainable in the factory function.

Flaskr may have two blueprints, one for verification functions plus one for the blog articles functions. The rule for every single blueprint is certainly going in a module that is separate. Considering that the we we blog has to find out about verification, you’ll write the verification one first.

This produces a Blueprint called ‘auth’ . The blueprint needs to know where it’s defined, so __name__ is passed as the second argument like the application object. The url_prefix shall be prepended to any or all the URLs from the blueprint.

Import and register the blueprint through the factory utilizing app.register_blueprint() . Continuar leyendo «A view function may be the code you compose to respond to needs to the application»