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.2.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for mvc_flask-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0760d05d7160bb6e0938b3c7c4f0c28ed70b4e783fc23c53e50bdcdab7d2e4d5 |
|
MD5 | d9c23979e9f49e085c9c5e19834f95bd |
|
BLAKE2b-256 | 9221246f235d6762e2fe47301f75f85ea3f24826fb3d56fc2e8ebc952f7a8cb7 |