A view function could be the code you compose to respond to needs to the job

A view function could be the code you compose to respond to needs to the job

Flask utilizes patterns to suit the incoming request Address to the view that will manage it. The view comes back data that Flask can become a outgoing reaction. Flask also can get one other way and produce A address to a view according to its title and arguments.

Create a Blueprint

A Blueprint is means to arrange a team of relevant views along with other rule. In place of registering views along with other rule straight with a software, these are generally registered by having a blueprint. Then your blueprint is registered with all the application when it’s for sale in the factory function.

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

This creates a Blueprint named ‘auth’ . Such as the application item, the blueprint has to understand where it is defined, therefore __name__ is passed because the 2nd argument. The url_prefix will be prepended to any or all the URLs from the blueprint.

Import and register the blueprint through the factory making use of app.register_blueprint() . Put the brand new rule at the conclusion for the factory function before going back the software. Continue reading «A view function could be the code you compose to respond to needs to the job»