GitHub code size in bytes GitHub Workflow Status GitHub PyPI - Downloads PyPI - Python Version PyPI

You can use the mvc pattern in your flask application using this extension.


Run the follow command to install mvc_flask:

$ pip install mvc_flask


To configure the mvc_flask you need import and register in your application:

from mvc_flask import FlaskMVC
mvc = FlaskMVC()

Or use factory function

mvc = FlaskMVC()

def create_app():

By default the mvc_flask assumes that your application directory will be app, but, you can change it. Passing the object of configuration:

app.config["FLASK_MVC_DIR"] = "sample_app"

Create MVC Pattern

mvc_flask assumes that your application will have these characteristics:

├── controllers
│   └──
├── models
├── routes.json
└── views
    ├── index.html

The routes.json file should be like this:

    "method": "GET",
    "path": "/",
    "controller": "home",
    "action": "index"

The file should be like this:

from flask.templating import render_template

class HomeController:
    def index(self):
        return render_template("index.html")


You can run the tests, executing the follow command:

$ make test