Code Monkey home page Code Monkey logo

flask_mvc's Introduction

flask_mvc.png

What is MVC?

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components is built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard web development frameworks` to create scalable and extensible projects.

Generally, Flask is actually not an MVC framework. It is a minimalistic framework which gives you a lot of freedom in how you structure your application, but MVC pattern is a very good fit for what Flask provides.

MVC Sructure:

base_mvc

This is how MVC app looks like , here flask_api is my app name , you can name it whatever you want , static folder contains our css files inside a css folder and images in images folder. Templates folder contains our html files whereas manage.py file contain host number to run app on particular local ip.

requirement.text file conatins packages information for installation.

MVC App folder layout:

main_mvc

As we can see, this app folder have bunch of files, i will explain each file functionalaty and purpose one by one.

  1. __init__.py this file use to initialise our app's urls and model , you can chek it.
  2. models.py this file is use to store data in database using ORM (object relational management sructure ) write now its empty but i will discuss in my upcoming post.
  3. settings.py file contains general setting regarding static , templates folder path , secret_key amd database details.
  4. urls.py file contains unique url for each functions which we defined in our views.py app.
  5. views.py this is core file of this app , it can contains multiple function , here we just write small functions just for bind up urls with app.

How to run this app ?

    • Install python by the following command
    • sudo apt-get python3-pip
    • Install requirement.txt file by the following command
    • pip install -r requirements.txt
  1. Now run the app on base dir where manage.py file is placed
  2. run this command here in your terminal python3 manage.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.