Does the Flask micro-framework use the Action Based or Component Based architecture?

Asked

Viewed 87 times

1

Was reading about the frameworks Action Based and Component Based. I have already used the Slim micro-framework and know that it is an Action Based framework, IE, more focused on actions, and the way to use it follows this concept a lot.

See an example (Slim):

$app->get('/index', App\Controllers\IndexAction::class);

Realize that the action is directed to a controlling class.

So, I’m using the Flask micro-framework and I’m studying on Blueprints which consists of dividing the application into components, see a small example:

bp_autenticacao = Blueprint('autenticacao', __name__, url_prefix='/autenticacao')

@bp_autenticacao.route('/registrar', methods=('GET', 'POST'))
def registrar():
    pass # Registrar usuário

Note that in flask the division consists of breaking the application into views and doing the views functions for each view of the application using the concept of Blueprints.

This approach of Flask left me with some doubts regarding the Action Based and Component Based architecture.

Doubts

  • Flask micro-framework uses the Action Based or Component architecture Based?
  • What characterizes Flask in case it uses one of the two architecture, where the actions or components are?
  • How these architectures in Flask work in case he uses them?

1 answer

0

Flask uses the Action Based architecture. This can be noticed especially when you map each route (endpoint) to a python function. Each route would be an Action.

Below an example of "Action" following the idea of the example you posted:

@app.get('/index')
def index():
    return "Hello World"

Component Based architectures further abstract the application structure, meaning they hide many things from the developer, making decisions for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.