Python Flask: pros and cons
Tags: python, flask
Published: 2019-11-18 15:37:51

<a href="https://flask.palletsprojects.com/en/1.1.x/">Flask</a> is a lightweight <a href="https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface">Web Server Gateway Interface (WSGI)</a> web application framework. 

A micro web framework that has minimal dependencies on external libraries, written in <a href="https://python.org">Python</a>, which was formed for a faster and easier use, and also has the ability to scale up to complex applications.

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fonaircode.com%2Fwp-content%2Fuploads%2F2017%2F08%2Fflask-python-framework-1024x553.png&f=1&nofb=1">

A developer is provided the required code by Flask when building a web application. It lets you start up a server, handle requests, templates and much more.

As a beginner in web development, you want to <a href="https://pythonbasics.org/flask-tutorial-hello-world/">know more about Flask</a>. Flask is considered the best framework for beginners due to its flexibility and gives you the opportunity to learn. Here are the advantages and disadvantages of the Flask web framework.

While Flask is simple enough to get started with, you should know the <a href="https://pythonprogramminglanguage.com">Python language</a> before starting.

## Advantages of the Flask framework

Flask is considered the best framework for light web application serving, it is a lightweight framework and can also be useful to the developer if he or she chooses a web interface to the default system based UI.

**Easy to understand development**
The Flask framework is easy to understand, that is why it is best for beginners. Its simplicity gives you the opportunity to understand it better and learn from it. There are interesting features to use in the framework. The simplicity in the flask framework enables the developer to navigate around and create the application easily.

Unlike other web application frameworks, flask let you be in total control in web development taking full creative control of the application and web development. The developer has the chance of being "in the drivers seat", taking charge of what you want to do like adding external features.

<img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fdocs.peewee-orm.com%2Fprojects%2Fflask-peewee%2Fen%2Flatest%2F_images%2Ffp-admin.jpg&f=1&nofb=1" alt="flask admin">

**It is very flexible and easy.**
There are only a handful of parts of flask that cannot be changed or altered because of its simplicity and minimalism. This means that almost all the parts of flask are open to change, unlike some other web frameworks.

Flask comes with a <a href="https://pythonbasics.org/flask-tutorial-templates/">template engine</a> that lets you use the same user interface for multiple pages. Python can insert variables into the templates.  

**Testing**
Using Flask for web development allows for unit testing through its integrated support, built-in development server, fast debugger, and restful request dispatching. It is lightweight to enable you to transit into a web framework easily with some extension. 

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxT4uQyKtTSwg4h9zd6%2Fgiphy.gif&f=1&nofb=1" alt="testing">

## Disadvantages of flask

As it is easy for an amateur or a beginner to learn and create a web development with flask framework, in the same way, a bad developer will write worse code, or in the case of a young developer in training, it will be easier for him to use low-quality code creating a "bad web application".

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F137EaR4vAOCn1S%2Fgiphy.gif&f=1&nofb=1">

**Scale**
Another issue about flask is that it has a singular source which means that it will handle every request in turns, one at a time. So if you are trying to serve multiple requests, it will take more time. With fewer tools at your disposal, you may need to install more modules. This could be mitigated by using Python specialized hosting.

**Modules**
Using more modules is seen as a third party involvement which could be a major breach in security. The process and development is no longer between the web framework and the developer, because of the involvement of other modules. That could increase the security risk if a malicious module is included. 

**Related links**
* <a href="https://pythonbasics.org/flask-tutorial-hello-world/">Flask beginners tutorial</a>
* <a href="https://flask.palletsprojects.com/en/1.1.x/">Python Flask module site</a>
* <a href="https://pythonprogramminglanguage.com/">Learn Python</a>