Design An MVC Model Using Python For Flask Framework Development
Design An MVC Model Using Python For Flask Framework Development
Abstract— The Model-View-Controller (MVC) web developers who use framework flask, MVC is needed in
framework has become the standard in modern software the framework flask.
development, with the model layer, display layer, and There have been several previous studies on the use of
controller layer making it easier and faster. The Flask is a MVC, including Sarker et al. [1] proposed the MVC design to
framework that uses Python language with easy to be implemented in the Java Framework in developing desktop
understand code writing. But the Flask framework still application research. In the proposed MVC it can separate data,
doesn't use the MVC method, so files and codes are not display, control software, and can also achieve the separation
regular. The purpose of this study was to design a MVC of the business logic layer and presentation layer. The results of
for a framework that uses the Python programming the research conducted show that software can be developed
language. This system has a generator that can make MVC effectively using this MVC framework, and this framework is
folder structure easily and quickly, this system is also also stable, efficient, and able to develop high-quality
equipped with the Bootstrap framework, and this system is applications.
open source. The results showed that the presence of MVC Paul et al. [3] proposes a model for developing fast web
on the flask framework could make users easier in creating applications based on the Model-View-Controller (MVC)
new projects and have faster fully load time. architecture which has several useful components such as
security, form validation and creation, as well as database
Keywords— Framework, Model-View-Controller (MVC),
access and routing. The proposed MVC model uses the PHP
Python, genarator
programming language, but can be implemented in other
I. INTRODUCTION languages and development environments using the same
concept. The results show that this model can reduce web
Today, the development of websites has been going a long application development time, and allow developers to focus
way since the beginning of the World Wide Web (WWW), on application specific tasks, rather than wasting time trying to
many programming technologies and languages are now being apply well-known patterns and practices.
used to build web applications. One of the technologies for
building web applications is MVC. MVC is a method for Xu et al. [4] proposed a study of the application of the
building web by separating the model layer, controller layer, MVC-based Struts framework to be applied in the online rural
and display layer so that it is easier and faster. MVC has shown teacher training system in China. This system is based on the
its benefits for interactive web applications that allow multiple J2EE platform, which provides types of components and
representations of the same information, promote code reuse, containers for program development in carrying out MVC
and help developers focus on certain application features. The roles, and makes development easier and more efficient.
MVC framework has broadly become a standard in modern Wang et al. [5] proposed the implementation of the
software development [1]. application of code reuse technology based on the MVC
Framework Flask is a web framework from Python concept applied to a comprehensive fishing vessel inspection
language. Flask provides a library and a collection of codes that service system project. The results of the study indicate that a
can be used to build websites, without the need to do combination of code reuse and MVC framework can improve
everything from scratch. Because of its simple features, the the efficiency of code development and maintenance.
flask will be lighter and not dependent on many external Zhang et al. [6] proposed research on the design of a
libraries that need attention. In general, the flask provides lightweight MVC framework based on Spring MVC and
'Wekzeug' which is useful for receiving requests (url) and Mybatis. Spring MVC can do method-level interceptors for
responding [2]. But Framework flask still doesn't use the requests to improve operating efficiency, and completely
Model View Controller (MVC) method. So there are separate business logic and display layers. Whereas by using
weaknesses including the difficulty in making repetitive codes Mybatis as a persistence layer framework, it can increase the
and source code management. Therefore, to make it easier for
215
Authorized licensed use limited to: PUC MG. Downloaded on April 24,2024 at 23:09:56 UTC from IEEE Xplore. Restrictions apply.
controller. The function of view block is to the user.
In this study to implement MVC on the framework flask, it Section views does not have direct access to the model
will be divided into the following stages: section.
• Model usually dealing directly with databases to
a) Create Project Generator manipulate data (insert, update, delete, search), handle
At this stage, this system has a project generator that will validation from controller parts, but it can’t deal directly
make folders and files structured and automatic, so users don't with the view section.
need to create manual folders and files. Figure 4 explains how • Controller is a part that regulates the relationship
to create a controller folder and create a __init__.py between the part of the model and the part of view, the
constructor file, to create a model folder, view, static, config is functions controller of is to receive requests and data
also the same as creating a controller folder, but the difference from the user then determine what the application will
in naming the variable. process.
• Static is for saving files css, javascript, and also to save
images.
• Config is part of managing database configuration and
other system configurations.
216
Authorized licensed use limited to: PUC MG. Downloaded on April 24,2024 at 23:09:56 UTC from IEEE Xplore. Restrictions apply.
created by the generator.
• In the config folder there are 2 python files, namely:
__init__.py is a constructor file that will read python
files that are in the config folder, and Database.py for
mysql database settings.
V. PERFORMANCE EVALUATION
In this section a testing process will be carried out to
determine the performance of the MVC model design on the
Flask framework using the Python language. In this test, it will
be divided into 2 parts, namely the implementation of website Fig. 9. Display Home
creation and analysis of the performance of Flask MVC.
Figure 10 is the display about connecting to controller
a) Implementation of website creation about.py.
To create a new website, using Flask MVC we just make it
from a project generator. the project generator will create
folders and files in a structured and automatic manner, so
users do not need to manually create folders and files. Figure 7
is a display of a generator project from Flask MVC. There is
one input to the project generator that is entering the name of
the project that we will create. After the project is created,
then the project will automatically have an MVC folder
structure that is also equipped with a web server named
Artisan.py. Figure 8 is the view to run the server, the user
must enter the project folder then open terminal / cmd, then
type "python artisan.py runserv", the system will run the Fig. 10. Display About
server and output the output to inform the user that the server
is running, then open the browser and enter the url http: // Figure 11 is the display contact connecting to controller
localhost: 8000 /. The system will look for a controller named contact.py.
index.py and will run it. Figure 9 is the start page view of a
website that is created automatically from the use of the MVC
Flask generator. The home view is connected to the index.py
controller.
217
Authorized licensed use limited to: PUC MG. Downloaded on April 24,2024 at 23:09:56 UTC from IEEE Xplore. Restrictions apply.
Google's rules. YSlow's score is the result of analyzing web
pages based on Yahoo's rules.
Fig. 13. Result Fully Loaded Time [3]. D. P. Pop, A. Altar, “Designing an MVC Model for
Rapid Web Application Development,” Elsevier Ltd,
Vol. 69, pp. 1172-1179, 2013.
[4]. S. Xu, T. Yang, “Application of Struts framework
based on MVC in Online Countryside Teachers’
Training System in China,” International Conference
on Multimedia Technology, IEEE, pp. 6252-6255,
2011.
[5]. X. Wang, B. Xu, R. Gu, “The Application of Code
Reuse Technology Based on the MVC Framework,”
International Conference on Computer Sciences and
Applications, IEEE, pp. 534-537, 2013.
[6]. D. Zhang, Z. Wei, Y. Yang, “Research on Lightweight
MVC Framework Based on Spring MVC and Mybatis,”
218
Authorized licensed use limited to: PUC MG. Downloaded on April 24,2024 at 23:09:56 UTC from IEEE Xplore. Restrictions apply.
International Symposium on Computational Intelligence
and Design on IEEE, Vol.1, pp. 350-353, 2013.
[7]. C. C. Pan, C. C. Lin, “Designing and Implementing a
Computerized Adaptive Testing System with an MVC
Framework: A Case Study of the IEEE Floating-Point
Standard,” International Conference on Applied System
Invention (ICASI), pp. 609-612, 2018.
[8]. A. Singh, P. Chawla, K. Singh, A. K. Singh,
“Formulating an MVC Framework for Web Development
in JAVA,” International Conference on Trends in
Electronics and Informatics (ICOEI), pp. 926-929, 2018.
[9]. K. Wijaya, A. Christian, “Implementasi Metode Model
View Controller (MVC) Dalam Rancang Bangun Website
SMK Yayasan Bakti Prabumulih,” Paradigma-Jurnal
Komputer dan Informatika, Vol. 21, No. 1, pp. 95-102,
2019.
219
Authorized licensed use limited to: PUC MG. Downloaded on April 24,2024 at 23:09:56 UTC from IEEE Xplore. Restrictions apply.