Frame Bottle: MVC Template

Does the flash frame support the MVC pattern in a natural way? What part of the application should I consider as a model, what as a representation, and what as a controller?

Typically (in my experience) a Flask application looks like this:

main_dir--|
          |
         app1--|
          |    |
          |  __init__.py
          |  api.py
          |  models.py
          |
         static--|
          |      |
          |    all the static stuff
          |
         app.py # with blueprints registering
+5
source share
1 answer

The flask is not really an MVC environment. This is a minimalist structure that gives you a lot of freedom in how you structure your application, but the MVC template is very suitable for what Flask offers.

Essentially, you write your methods and map them to a specific route, for example:

@app.route("/")
def hello():
    return "Hello World!"

, . , Jinja2, ( ) :

@app.route("/")
def hello():
    return render_template('index.html', username="John Doe")

index.html . .

. , , - ( , ORM, SQLAlchemy), , .

: MVC

+8

All Articles