Introduction
This extension facilitates the application of this design pattern in Flask
Designed to allow developers to implement the Model-View-Controller (MVC) design pattern in Flask applications with the help of this extension.
Install MVC Flask using pip:
$ pip install mvc_flask
Install MVC Flask using poetry:
$ poetry add mvc_flask
Now, let's get started:
from flask import Flask
from mvc_flask import FlaskMVC
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app():
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///blog.db'
# registering extensions
FlaskMVC(app)
db.init_app(app)
return app
Features
MVC Flask builds on provides the best architecture experience for Flask, and gives you:
- You can directories as controllers, models, and views.
- It Supports the controllers' creation, and you can separate the logic of your application of business rules
- You can separate routes of business rules
- You can use the before_action to execute a specific code
- You can integrate with other extensions of Flask, Flask-SQLAlchemy, Flask-Migrate, etc.
Dependencies
MVC Flask just depends on the Flask extensions to working and requires Python >=3.8.0,<4.0.0.