turn standard flask into mvc
Project description
You can use the mvc pattern in your flask application using this extension.
Installation
Run the follow command to install mvc_flask
:
$ pip install mvc_flask
Configuration
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():
...
mvc.init_app(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:
app
├── __ini__.py
├── controllers
│ ├── contact_controller.py
│ └── home_controller.py
├── model
├── routes.json
└── views
├── index.html
└── post
└── new.html
The routes will be something as:
[
{
"method": "GET",
"path": "/",
"controller": "home",
"action": "index"
},
{
"method": "get",
"path": "/new",
"controller": "home",
"action": "new"
},
{
"method": "post",
"path": "/create",
"controller": "home",
"action": "create"
},
{
"method": "GET",
"path": "/contact",
"controller": "contact",
"action": "index"
}
]
Tests
You can run the tests, executing the follow command:
$ make test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mvc-flask-1.0.1.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for mvc_flask-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0710017d916f2c9343430423696c3fde01731b26d30850e0d218d769e469ac |
|
MD5 | e8b3992585c2fdb1a623a324a988fecf |
|
BLAKE2b-256 | 88d5fb0bc0aed4fd9df0fd0445a941c3951308c1ebe34f4228b79731ae6bffd2 |